Skip to content

Commit

Permalink
codec_tester: split u16 and u64 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Aug 18, 2022
1 parent 20952b7 commit b563b39
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions protocol/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,21 @@ func TestRandomizeObjectWithPtrField(t *testing.T) {
}

// run a few and fail if all ints are zero
sawNonZeroInt := false
sawNonZeroU16 := false
sawNonZeroU64 := false
for i := 0; i < 10; i++ {
obj, err := RandomizeObject(&testObjB{})
require.NoError(t, err)
objB, ok := obj.(*testObjB)
require.True(t, ok)
require.NotNil(t, objB.ObjA)
if objB.U16 != 0 || objB.ObjA.U64 != 0 {
sawNonZeroInt = true
if objB.U16 != 0 {
sawNonZeroU16 = true
}
if objB.ObjA.U64 != 0 {
sawNonZeroU64 = true
}
}
require.True(t, sawNonZeroInt, "RandomizeObject made all zeroes for ints")
require.True(t, sawNonZeroU16, "RandomizeObject made all zeroes for testObjB.U16")
require.True(t, sawNonZeroU64, "RandomizeObject made all zeroes for testObjA.U64")
}

0 comments on commit b563b39

Please sign in to comment.