diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-23 04:46:46 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-23 04:46:46 +0800 |
commit | 8affdf96e23f092b7fe24d168b024b10eab35e05 (patch) | |
tree | 3d29fe62226a54a8f22d194df03224c7625e1312 /common/bytes_test.go | |
parent | 3133372a6a81c91528afbde58e22b3f9df257d03 (diff) | |
parent | bf73f02fe040086ac7c9786a15fadc65840a8536 (diff) | |
download | dexon-8affdf96e23f092b7fe24d168b024b10eab35e05.tar.gz dexon-8affdf96e23f092b7fe24d168b024b10eab35e05.tar.zst dexon-8affdf96e23f092b7fe24d168b024b10eab35e05.zip |
Merge pull request #547 from tgerring/commoncleanup
common/common.go cleanup
Diffstat (limited to 'common/bytes_test.go')
-rw-r--r-- | common/bytes_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/bytes_test.go b/common/bytes_test.go index ec106bf4b..4b00aa49b 100644 --- a/common/bytes_test.go +++ b/common/bytes_test.go @@ -1,6 +1,9 @@ package common import ( + "bytes" + "testing" + checker "gopkg.in/check.v1" ) @@ -191,3 +194,21 @@ func (s *BytesSuite) TestRightPadString(c *checker.C) { c.Assert(resstd, checker.Equals, exp) c.Assert(resshrt, checker.Equals, val) } + +func TestFromHex(t *testing.T) { + input := "0x01" + expected := []byte{1} + result := FromHex(input) + if bytes.Compare(expected, result) != 0 { + t.Errorf("Expected % x got % x", expected, result) + } +} + +func TestFromHexOddLength(t *testing.T) { + input := "0x1" + expected := []byte{1} + result := FromHex(input) + if bytes.Compare(expected, result) != 0 { + t.Errorf("Expected % x got % x", expected, result) + } +} |