time encoding in binary/reflect

This commit is contained in:
Jae Kwon
2015-01-06 15:51:41 -08:00
parent d4e9b747d3
commit 325b88b083
11 changed files with 234 additions and 117 deletions

View File

@ -4,11 +4,13 @@ import (
"bytes"
"reflect"
"testing"
"time"
)
type SimpleStruct struct {
String string
Bytes []byte
Time time.Time
}
//-------------------------------------
@ -75,6 +77,7 @@ func constructBasic() interface{} {
SimpleStruct{
String: "String",
Bytes: []byte("Bytes"),
Time: time.Unix(123, 0),
},
}
return cat
@ -92,6 +95,9 @@ func validateBasic(o interface{}, t *testing.T) {
if string(cat.Bytes) != "Bytes" {
t.Errorf("Expected cat2.Bytes == 'Bytes', got %X", cat.Bytes)
}
if cat.Time.Unix() != 123 {
t.Errorf("Expected cat2.Time == 'Unix(123)', got %v", cat.Time)
}
}
//-------------------------------------