aboutsummaryrefslogtreecommitdiffstats
path: root/utils/binary/read_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/binary/read_test.go')
-rw-r--r--utils/binary/read_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/binary/read_test.go b/utils/binary/read_test.go
index 59dbc30..5674653 100644
--- a/utils/binary/read_test.go
+++ b/utils/binary/read_test.go
@@ -85,3 +85,27 @@ func (s *BinarySuite) TestReadHash(c *C) {
c.Assert(err, IsNil)
c.Assert(hash.String(), Equals, expected.String())
}
+
+func (s *BinarySuite) TestIsBinary(c *C) {
+ buf := bytes.NewBuffer(nil)
+ buf.Write(bytes.Repeat([]byte{'A'}, sniffLen))
+ buf.Write([]byte{0})
+ ok, err := IsBinary(buf)
+ c.Assert(err, IsNil)
+ c.Assert(ok, Equals, false)
+
+ buf.Reset()
+
+ buf.Write(bytes.Repeat([]byte{'A'}, sniffLen-1))
+ buf.Write([]byte{0})
+ ok, err = IsBinary(buf)
+ c.Assert(err, IsNil)
+ c.Assert(ok, Equals, true)
+
+ buf.Reset()
+
+ buf.Write(bytes.Repeat([]byte{'A'}, 10))
+ ok, err = IsBinary(buf)
+ c.Assert(err, IsNil)
+ c.Assert(ok, Equals, false)
+}