diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-28 19:21:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-28 19:21:12 +0800 |
commit | 839bd73fbb525f6c51e4205ce6519b6154cda2f0 (patch) | |
tree | 8bbb80d53425cfdb0391798eea77ff3af09ffe78 /ethutil/value_test.go | |
parent | 30ee32a7254658878b35c6a89e463427f99bd1b4 (diff) | |
parent | 3f7ec1a83fe13dc934d92a405ff01b0be6c04ac0 (diff) | |
download | dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar.gz dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar.bz2 dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar.lz dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar.xz dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.tar.zst dexon-839bd73fbb525f6c51e4205ce6519b6154cda2f0.zip |
Merge branch 'release/0.3.0'
Diffstat (limited to 'ethutil/value_test.go')
-rw-r--r-- | ethutil/value_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ethutil/value_test.go b/ethutil/value_test.go new file mode 100644 index 000000000..0e2da5328 --- /dev/null +++ b/ethutil/value_test.go @@ -0,0 +1,52 @@ +package ethutil + +import ( + "bytes" + "math/big" + "testing" +) + +func TestValueCmp(t *testing.T) { + val1 := NewValue("hello") + val2 := NewValue("world") + if val1.Cmp(val2) { + t.Error("Expected values not to be equal") + } + + val3 := NewValue("hello") + val4 := NewValue("hello") + if !val3.Cmp(val4) { + t.Error("Expected values to be equal") + } +} + +func TestValueTypes(t *testing.T) { + str := NewValue("str") + num := NewValue(1) + inter := NewValue([]interface{}{1}) + byt := NewValue([]byte{1, 2, 3, 4}) + bigInt := NewValue(big.NewInt(10)) + + if str.Str() != "str" { + t.Errorf("expected Str to return 'str', got %s", str.Str()) + } + + if num.Uint() != 1 { + t.Errorf("expected Uint to return '1', got %d", num.Uint()) + } + + interExp := []interface{}{1} + if !NewValue(inter.Interface()).Cmp(NewValue(interExp)) { + t.Errorf("expected Interface to return '%v', got %v", interExp, num.Interface()) + } + + bytExp := []byte{1, 2, 3, 4} + if bytes.Compare(byt.Bytes(), bytExp) != 0 { + t.Errorf("expected Bytes to return '%v', got %v", bytExp, byt.Bytes()) + } + + bigExp := big.NewInt(10) + if bigInt.BigInt().Cmp(bigExp) != 0 { + t.Errorf("expected BigInt to return '%v', got %v", bigExp, bigInt.BigInt()) + } +} |