2016-02-03 23:55:33 -08:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIntegerBigEndian(t *testing.T) {
|
|
|
|
bytes := []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
|
2016-02-04 00:54:51 -08:00
|
|
|
i := Integer(bytes)
|
2016-02-03 23:55:33 -08:00
|
|
|
if i != 1 {
|
|
|
|
t.Fatal("Integer() not big endian")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 00:54:51 -08:00
|
|
|
func TestWorksWith1Byte(t *testing.T) {
|
|
|
|
i := Integer([]byte{0x01})
|
2016-02-03 23:55:33 -08:00
|
|
|
if i != 1 {
|
|
|
|
t.Fatal("Integer() does not work with 1 byte")
|
|
|
|
}
|
|
|
|
}
|
2016-02-14 22:40:29 -08:00
|
|
|
|
|
|
|
func TestIsZeroWithNoData(t *testing.T) {
|
|
|
|
i := Integer([]byte{})
|
|
|
|
if i != 0 {
|
|
|
|
t.Fatal("Integer() does not work with 0 bytes")
|
|
|
|
}
|
|
|
|
}
|