-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tests #1
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
==========================================
- Coverage 91.80% 90.65% -1.15%
==========================================
Files 1 1
Lines 122 107 -15
==========================================
- Hits 112 97 -15
Misses 5 5
Partials 5 5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggesting the PR. Sorry it took me so long to review it--I just haven't checked this repo in a very long time 😬
) | ||
|
||
func ExampleAnything() { | ||
func TestExampleAnything(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example test, so the method is named and implemented so that it shows up as an example in the godoc.
https://pkg.go.dev/github.com/barkimedes/go-deepcopy#pkg-examples
For more info on example tests: https://go.dev/blog/examples
// 2.14 | ||
// [Phil Harris Rochester van Jones Mary Livingstone Dennis Day] | ||
// [Jell-O Grape-Nuts] | ||
if !DeepEqual(expected, actual) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this would make the example not work anymore, so we can drop this suggestion.
} | ||
|
||
type Foo struct { | ||
Foo *Foo | ||
Bar int | ||
} | ||
|
||
func ExampleMap() { | ||
func TestExampleMap(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this example doesn't actually show up in the docs (I got rid of copying map as a public interface), we can rename this one, just take out "Example"
(Make it TestMap
)
@@ -77,19 +71,22 @@ func TestInterface(t *testing.T) { | |||
} | |||
} | |||
|
|||
func ExampleAvoidInfiniteLoops() { | |||
func TestExampleAvoidInfiniteLoops(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, can just make it TestAvoidInfiniteLoops
TestXXX
conventiont.Errorf
to replace some manual output comparison testsquick.Check
test to automatically test non-pointer copies