Why does deep equal return false even thought both errors are the same?

Written by
Link to Post

https://www.reddit.com/r/golang/comments/b070vp/why_does_deep_equal_return_false_even_thought/ by 

I have a test in which the last test case that should raise and error is failing because the expected and actual error messages provided turn out to be unequal even though they are exactly the same

var reindexedNamesTest = []struct { index string expected string err error }{ { "twitter_reindexed_2", "twitter_reindexed_3", nil, }, { "twitter_reindexed_1@", "", errors.New("strconv.Atoi: parsing "1@": invalid syntax"), }, } func TestReindexedName(t *testing.T) { for _, tt := range reindexedNamesTest { actual, err := reindexedName(tt.index) if !reflect.DeepEqual(actual, tt.expected) { t.Fatalf("Reindexed name mismatch, expected: %s got: %sn", tt.expected, actual) } if !reflect.DeepEqual(err, tt.err) { t.Fatalf("Reindexed name error mismatch, expected: %s got: %sn", tt.err, err) } } } 

Why is it so?

submitted by /u/fenster25
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply