Skip to content

cmp,cmpopts: add examples for AllowUnexported and IgnoreUnexported#392

Draft
MukundaKatta wants to merge 1 commit intogoogle:masterfrom
MukundaKatta:docs/examples-unexported
Draft

cmp,cmpopts: add examples for AllowUnexported and IgnoreUnexported#392
MukundaKatta wants to merge 1 commit intogoogle:masterfrom
MukundaKatta:docs/examples-unexported

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

Fixes #130. Adds testable Example functions for cmp.AllowUnexported and cmpopts.IgnoreUnexported that demonstrate the difference between the two options on a struct with an unexported field.

What's added

  • cmp/example_test.goExampleAllowUnexported (account struct with unexported balance; equal vs unequal cases plus cmp.Diff output).
  • cmp/cmpopts/example_test.goExampleIgnoreUnexported (user struct with unexported cache; equal-despite-differing-cache case plus the "1 ignored field" diff).

Each example has an // Output: block so go test verifies it. Style follows the existing ExampleDiff_testing and ExampleIgnoreFields_testing patterns.

Test plan

  • go test ./cmp -run Example -v — all example tests pass.
  • go test ./... — full suite green.
  • gofmt -l clean.

Add testable examples demonstrating cmp.AllowUnexported and
cmpopts.IgnoreUnexported. Each example uses a small struct with one
unexported field, shows the equal/non-equal cases, and prints a Diff
to clarify how the option affects the output.

Fixes google#130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add examples for AllowUnexported and IgnoreUnexported

1 participant