26 lines
594 B
Go
26 lines
594 B
Go
package libnmdc
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTTH(t *testing.T) {
|
|
|
|
// echo -n 'hello world' | tthsum
|
|
testCases := [][2]string{
|
|
[2]string{"hello world", "ZIIVRZDR2FD3W4KKNMNYUU3765LPPK7BWY64CHI"},
|
|
[2]string{"", "LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ"},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
input, expected := testCase[0], testCase[1]
|
|
result, err := tth([]byte(input))
|
|
if err != nil {
|
|
t.Fatalf("Error getting TTH for '%s': %s", input, err.Error())
|
|
}
|
|
if result != expected {
|
|
t.Fatalf("Wrong TTH for '%s' (got '%s' expected '%s')", input, result, expected)
|
|
}
|
|
}
|
|
}
|