Vincent Cote-Roy
88a414d072
generalize Empty assertion
...
Make `Empty` work against any struct and custom types, by replacing
explicit zero value comparisons with a `DeepEqual` comparison with
the type's `reflect.ZeroValue`.
2017-12-30 13:03:09 +01:00
Joshua T Corbin
2f1cd6b778
time.Duraions are numbers too
2017-07-14 14:27:08 -07:00
Tom Artale
f6abca5936
Added assert.PanicsWithValue + tests
2017-06-01 22:03:22 +01:00
Adam Medzinski
46b3c8225b
Simple validation of Equal/NotEqual assertion arguments
2017-05-29 17:57:31 +01:00
Ernesto Jiménez
c7668ea997
Fixes #339 - Add `assertion`f assertions like Errorf and Equalf
2017-05-29 12:56:43 +01:00
Ernesto Jiménez
c33f336b92
Fix vet warnings and go generate to update docs
2017-05-29 12:56:43 +01:00
decauwsemaecker.glen@gmail.com
3a59a58abc
add Subset and NotSubset assertions
2017-05-27 17:24:18 -05:00
Cameron Moore
09f61d78b8
assert: fix error reporting when error contains escape sequences
...
Fixes #325
2017-05-25 17:28:59 -07:00
havnesvo
bc11a6e4dd
Tighten language by increasing overall consistency in wording in texts and argument names: use 'actual' instead of 'received'
2017-05-25 17:16:55 -07:00
Denys Smirnov
97c0e43cd5
compare bytes with bytes.Equal instead of reflect.DeepEqual
2017-05-25 17:04:05 -07:00
Ernesto Jiménez
332ae0e18f
Add Equal test comparing nil with non-nil
2017-01-30 11:25:29 +00:00
Ernesto Jiménez
2402e8e7a0
Merge pull request #364 from nmiyake/fixFailOutput
...
Ensure that assert.Fail properly align its output
2016-12-17 14:04:45 -06:00
Ernesto Jiménez
ae4c58e530
Merge pull request #367 from packrat386/rm_numeric_check
...
Remove isNumericType check
2016-12-17 13:26:48 -06:00
Nick Miyake
3928f579ee
Add comments for Equal and NotEqual to clarify pointer comparison
...
Clarify that pointer equality is determined by equality of values
rather than memory address.
Fixes #358
2016-11-19 23:31:18 -08:00
Aidan Coyle
6835870125
Remove isNumericType check
...
I'm not sure why this check is needed. It seems worthwhile to print the
type any time the types aren't equal. Closes #366 .
2016-11-17 10:29:04 -06:00
Nick Miyake
ddb91ee140
Ensure that assert.Fail properly align its output
...
Previous implementation depended on tab alignment. This worked
when the output was not prepended with anything, but would break
if the output was prepended with further spaces (which can occur
in environments like IntelliJ test runners). This commit fixes it
so that the output is always aligned logically.
Fixes #83
2016-10-28 19:36:52 -07:00
Ernesto Jiménez
69483b4bd1
Merge pull request #327 from jveski/issue-155
...
Clarify assert.Equal failure message given mismatched numeric types
2016-09-25 02:54:16 +01:00
Jordan Olshevski
d2b5f58808
Add formatUnequalValues struct test coverage
...
This expands the TestFormatUnequalValues test case to cover the behavior
of the function when provided two struct type'd values.
2016-09-24 17:22:54 -07:00
Michael Broll
3656ffd69b
write test to simulate parallel execution of diff()
2016-09-06 17:15:19 -07:00
Jordan Olshevski
3bfb674961
Print types in failed numeric equality assertions
...
This addresses vague and misleading output when asserting on the
equality of two values of differing numeric types.
Example: assert.Equal(t, int64(123), int32(123))
Previously, the user would have received a vague message claiming that
123 != 123. Now the message will read "int64(123) != int32(123)".
2016-07-06 18:38:55 -07:00
Ernesto Jiménez
d77da356e5
Fixes #311 - Detect empty interface error gotcha
2016-06-15 11:28:44 +02:00
Ernesto Jiménez
0f6478d3a8
Fixes #257 - InEpsilon works when actual == 0
...
Implemented new InEpsilon by calculating the relative error and
comparing it to the expected epsilon rather than calculating the
acceptable margin and using InDelta.
While doing so we got rid of the false failure when the actual value
was zero.
2016-01-09 17:37:37 +01:00
Ernesto Jiménez
3dad6b7b59
Add tests for workaround solution to #263
2016-01-09 02:56:16 +01:00
Cyrill Schumacher
cd2b6c1151
Add check for empty time.Time struct (non pointer)
...
The standard library returns always a non-pointer Time type.
2016-01-07 07:55:48 +01:00
Ernesto Jiménez
67106a5111
Sort map keys before diffing maps
2015-11-11 20:37:34 +01:00
Matt Joiner
7d6ace9113
Handle case where one object is nil and the other is not
2015-11-07 19:02:25 +11:00
Ernesto Jiménez
a76410419d
Merge pull request #232 from stretchr/issue-136
...
Fix #136 - Empty returns true for nil pointers
2015-11-07 04:46:19 +00:00
Ernesto Jiménez
33c4c93911
Fixes #229 - show diffs for structs/maps/arrays/slices when Equal fails
2015-11-03 01:32:38 +00:00
Ernesto Jiménez
c478a808a1
Fix #136
2015-11-02 01:41:59 +00:00
Ernesto Jiménez
40b02b9eef
Merge pull request #165 from tuvistavie/master
...
Support map keys for Contains/NotContains assertion.
2015-11-01 21:02:28 +00:00
Ernesto Jiménez
a0534acc7b
Merge pull request #217 from juliancooper/assert-equivalent-json
...
Added assertion/requirement that checks if two JSON strings represent equivalent objects
2015-11-01 20:45:50 +00:00
Julian Cooper
7f6cb13c5c
split JSONEq tests into individual assertions from one monolithic test
2015-10-13 13:36:47 -07:00
Bryan Matsuo
ee60e76e54
Test Nil assertion behavior for typed nil values
2015-09-24 10:02:27 -07:00
Bryan Matsuo
fb64a0ab08
Fix NotNil assertion for typed nil values
...
The NotNil assertion had an error in its handling of typed nil values.
This change makes use of the helper function isNil (used by the Nil
assertion). The helper function has correct handling of typed nil
values and when negated provides the expected semantics for
`assert.NotNil(t, x)`.
if x == nil {
assert.Fail(t, "is nil", x)
}
2015-09-23 23:48:02 -07:00
Julian Cooper
930ea90dbd
Added assertion/requirement that checks if two JSON strings represent equivalent objects
2015-09-23 10:34:52 -07:00
Will Faught
8512261d41
Add Zero and NotZero assertions and requirements
...
Zero returns true if the value equals the value's type's zero value.
NotZero returns the opposite of Zero.
2015-08-24 15:53:36 -07:00
Ernesto Jiménez
ddcad49ec6
Fix typo in test function name
2015-06-15 21:31:24 +01:00
Ernesto Jiménez
abc938a12b
Add test to avoid regression of issue #180
2015-06-14 19:29:18 +01:00
Daniel Perez
1e710e53ab
Support map keys for Contains/NotContains assertion.
2015-05-13 16:07:31 +09:00
Michael R. Maletich
4e2053a4af
Address #162 : InDelta should fail when actual value is not a number.
...
Comparting a float with NaN is always false so the assertion would always pass.
Added a check that either the actual or expected values are NaN.
InDelta will now fail if either the actual or expected value are NaN.
2015-05-12 11:54:42 +00:00
Davide D'Agostino
3b361f7ebb
Merge pull request #134 from lazywei/master
...
Add InDeltaSlice.
2015-04-18 12:10:15 -07:00
Chih-Wei Chang
8b75665fbf
Add InEpsilonSlice and corresponding testing.
2015-04-18 22:40:21 +08:00
Tyler Bunnell
4f9c9aeeaa
Don't handle func comparisons
2015-04-16 11:41:42 -06:00
Paul Querna
e73f5c7e39
Add assert.EqualValues, which attempts to convert types to test equality. Fixes #129
2015-02-10 16:56:43 -08:00
Arnaud Porterie
9bab92ede2
Exclude conversions from equality tests
...
`ObjectsAreEqual` using `ConvertibleTo` causes the `ObjectsAreEqual`
function to be asymmetrical and producing incorrect assertions.
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-02-06 16:08:28 -08:00
Tyler
2eaa4b48b8
Merge pull request #110 from cryptix/master
...
added tests from PR #103
2014-12-22 10:16:26 -07:00
Tyler Bunnell
d1472b75d1
fix merge conflict
2014-12-22 10:15:32 -07:00
Henry
7a9121a162
added tests from PR #103
2014-12-17 16:41:45 +01:00
Neil Conway
38aecdc957
Fix panic when comparing unequal maps.
...
The change in #94 resulted in using == to compare two values that might not be
comparable. Hence, this resulted in a panic for situations like:
ObjectsAreEqual(map[int]int{5: 10}, map[int]int{10: 20})
The fix is to use reflect.DeepEqual() instead.
2014-11-24 16:11:51 -08:00
Victor Kryukov
d3556349dd
Fix #99 : Contains doesn't work for complex types
2014-11-18 15:26:31 -08:00