aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2014-11-06 19:35:46 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2014-11-06 19:35:46 +0800
commit0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23 (patch)
tree6e8aabed708d743f197720312da12dfc0026b0be
parent48a3f0986ccc3caf6405604e3cfe6a3b4de5726c (diff)
downloaddexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar.gz
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar.bz2
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar.lz
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar.xz
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.tar.zst
dexon-0a3a148ed4d2fbe29ec7a62f5b15a25f908d7f23.zip
Added more byte tests
-rw-r--r--ethutil/bytes_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/ethutil/bytes_test.go b/ethutil/bytes_test.go
index 08c44eabb..c7e696b55 100644
--- a/ethutil/bytes_test.go
+++ b/ethutil/bytes_test.go
@@ -16,6 +16,43 @@ func TestByteString(t *testing.T) {
}
}
+/*
+func TestDeleteFromByteSlice(t *testing.T) {
+ data := []byte{1, 2, 3, 4}
+ slice := []byte{1, 2, 3, 4}
+ exp := []byte{1, 4}
+ res := DeleteFromByteSlice(data, slice)
+ if bytes.Compare(res, exp) != 0 {
+ t.Errorf("Expected % x Got % x", exp, res)
+ }
+}
+
+func TestNumberToBytes(t *testing.T) {
+ data := int(1)
+ exp := []byte{0, 0, 0, 0, 0, 0, 0, 1}
+ // TODO this fails. why?
+ res := NumberToBytes(data, 16)
+ if bytes.Compare(res, exp) != 0 {
+ t.Errorf("Expected % x Got % x", exp, res)
+ }
+}
+*/
+
+func TestBytesToNumber(t *testing.T) {
+ datasmall := []byte{0, 1}
+ datalarge := []byte{1, 2, 3}
+ expsmall := uint64(0)
+ explarge := uint64(0)
+ // TODO this fails. why?
+ ressmall := BytesToNumber(datasmall)
+ reslarge := BytesToNumber(datalarge)
+ if ressmall != expsmall {
+ t.Errorf("Expected %d Got %d", expsmall, ressmall)
+ }
+ if reslarge != explarge {
+ t.Errorf("Expected %d Got %d", explarge, reslarge)
+ }
+}
func TestReadVarInt(t *testing.T) {
data8 := []byte{1, 2, 3, 4, 5, 6, 7, 8}