go-xim/serialize_test.go

33 lines
751 B
Go
Raw Normal View History

2021-11-08 05:10:49 +00:00
package xim
2021-11-07 07:50:42 +00:00
import (
"testing"
)
func TestSerialize(t *testing.T) {
2021-11-07 22:34:30 +00:00
for testNumber, test := range stdtests {
2021-11-07 07:50:42 +00:00
var serialized string = serialize(test.Value)
actual, successful := unserialize(serialized)
if !successful {
t.Errorf("For test #%d, expected unserialization of serialized data to be successful but wasn't." , testNumber)
2021-11-08 00:42:42 +00:00
t.Logf("SERIALIZED: %s", serialized)
2021-11-07 07:50:42 +00:00
t.Logf("SUCCESSFUL: %t", successful)
t.Logf("VALUE: %064b", test.Value)
continue
}
if expected := test.Value; expected != actual {
t.Errorf("For test #%d, ", testNumber)
2021-11-08 00:42:42 +00:00
t.Logf("SERIALIZED: %s", serialized)
2021-11-07 07:50:42 +00:00
t.Logf("SUCCESSFUL: %t", successful)
t.Logf("EXPECTED: %064b", expected)
t.Logf("ACTUAL: %064b", actual)
continue
}
}
}