Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Improve tests #1

wants to merge 5 commits into from

Conversation

lhl2617
Copy link

@lhl2617 lhl2617 commented Apr 25, 2021

  • Rename tests to follow TestXXX convention
  • Use t.Errorf to replace some manual output comparison tests
  • Add a quick.Check test to automatically test non-pointer copies

@codecov-commenter
Copy link

Codecov Report

Merging #1 (7ca4b25) into master (a044a19) will decrease coverage by 1.14%.
The diff coverage is n/a.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
deepcopy.go 90.65% <0.00%> (-1.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a044a19...7ca4b25. Read the comment docs.

Copy link
Owner

@barkimedes barkimedes left a 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) {
Copy link
Owner

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) {
Copy link
Owner

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) {
Copy link
Owner

@barkimedes barkimedes May 14, 2022

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) {
Copy link
Owner

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

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.

3 participants