1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2025-01-12 15:17:07 +00:00

adding the first efforts for testing this tool

This commit is contained in:
Vincent Batts 2013-02-13 22:30:50 -05:00
parent 51ff306fd9
commit 7ba7c07041
2 changed files with 41 additions and 1 deletions

View file

@ -1,11 +1,11 @@
package main
import (
"math/rand"
"crypto/md5"
"fmt"
"hash/adler32"
"io"
"math/rand"
"time"
)

40
hash_test.go Normal file
View file

@ -0,0 +1,40 @@
package main
import (
"fmt"
"testing"
)
func TestRand64(t *testing.T) {
var i interface{}
i = Rand64()
v, ok := i.(int64)
if (!ok) {
t.Errorf("Rand64 returned wrong type")
}
if (v < 0) {
t.Errorf("Rand64 returned a too small number [%d]", v)
}
}
func TestMd5Bytes(t *testing.T) {
var blob = []byte("Hurp til you Derp")
var expected = "3ef08fa896a154eee3c97f037c9d6dfc"
var actual = fmt.Sprintf("%x", GetMd5FromBytes(blob))
if (actual != expected) {
t.Errorf("Md5FromBytes sum did not match! %s != %s",actual,expected)
}
}
func TestMd5String(t *testing.T) {
var blob = "Hurp til you Derp"
var expected = "3ef08fa896a154eee3c97f037c9d6dfc"
var actual = fmt.Sprintf("%x", GetMd5FromString(blob))
if (actual != expected) {
t.Errorf("Md5FromString sum did not match! %s != %s",actual,expected)
}
}
func TestHash(t *testing.T) {
}