Comments (4)
This is an interesting example. Indeed, these two values will fail all of ObjectsAreEqual
tests:
a b: []byte{} []byte(nil)
a==nil b==nil: false true
a DeepEqual b: false
aValue == bValue: false
aValue convertible to bValue: true
bValue convertible to aValue: true
aValue converted to bValue == bValue: false
bValue converted to aValue == aValue: false
BTW, fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual)
is not covered by tests, and when I was working on #76, I couldn't come up with anything that would fail all the previous comparisons in ObjectsAreEqual
but not this one.
Hopefully someone more enlightened about Go reflection could provide some insight here.
from testify.
The Nil section at http://blog.golang.org/slices describes the difference between empty and nil slices of the same type, specifically:
As should be clear, an empty slice can grow (assuming it has non-zero capacity), but a nil slice has no array to put values in and can never grow to hold even one element.
That said, a nil slice is functionally equivalent to a zero-length slice, even though it points to nothing. It has length zero and can be appended to, with allocation.
Based on the above, I would say the ObjectsAreEqual
behavior is correct in this case.
from testify.
See also this: https://groups.google.com/d/msg/golang-nuts/QrItXLz3jis/NubiAVy9F6sJ
from testify.
Victor, I agree with you. It was a mistake in go and they fixed it. But behavior of testify is different on go 1.2 and 1.3. I think I'll close this bug and leave it for the history.
from testify.
Related Issues (20)
- assert: EqualBody to check if two io.Readers have same data HOT 1
- suite.TestTeardown fail/panic is shadowing the cause panic HOT 2
- proposal: analogue of `InDeltaMapValues` with different deltas HOT 2
- proposal: new assertion`InEpsilonMapValues` HOT 3
- assert package deserve to be STD HOT 1
- Detect and fail on `require.*` methods called from a wrong goroutine HOT 5
- suite: TestSubtestPanic is failing HOT 6
- suite: missing signature check before calling Test* method HOT 3
- Support colorized output, indentation in accordance with subtest depth, and one more assertion HOT 3
- wall clock HOT 10
- assert.EqualExportedValues - panic: reflect.MakeSlice of non-slice type [recovered] HOT 6
- `suite.Require` deadlock HOT 1
- Assert: go test output shows subtests that fail as PASS HOT 3
- `YAMLEq` does not validate YAML HOT 1
- Is it possible to assert for multiple allowed values? HOT 2
- Proposal: guard or support comparing with untyped nil HOT 5
- assert/require.Len doesn't print anything if the slice is too long HOT 7
- Allow user to skip (ignore) specific caller frames in assert.CallerInfo() HOT 1
- Unexpected call when interface is parameter HOT 4
- How can I get coverage in the Suite package HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testify.