aboutsummaryrefslogtreecommitdiff
path: root/objects/object_test.go
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2017-06-25 10:20:26 +0200
committerLaria Carolin Chabowski <laria@laria.me>2017-06-25 17:44:49 +0200
commitfb14fb157c0835d61cbc7f8425d89b941bd0ab16 (patch)
treeeb8a1d6e00cd4024f2f088326853be2174e7869d /objects/object_test.go
parent82dd9f540be12c4c93679d2a60c4d1950e57eec8 (diff)
downloadpetrific-fb14fb157c0835d61cbc7f8425d89b941bd0ab16.tar.gz
petrific-fb14fb157c0835d61cbc7f8425d89b941bd0ab16.tar.bz2
petrific-fb14fb157c0835d61cbc7f8425d89b941bd0ab16.zip
Implement object IDs
Diffstat (limited to 'objects/object_test.go')
-rw-r--r--objects/object_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/objects/object_test.go b/objects/object_test.go
index c596b39..54b33db 100644
--- a/objects/object_test.go
+++ b/objects/object_test.go
@@ -86,3 +86,21 @@ func TestSerialize(t *testing.T) {
t.Errorf("Unexpected serialization result: %v", b)
}
}
+
+func TestSerializeAndId(t *testing.T) {
+ o := Object{
+ Type: OTBlob,
+ Payload: []byte("foo bar\nbaz"),
+ }
+
+ buf := new(bytes.Buffer)
+ id, err := o.SerializeAndId(buf, OIdAlgoDefault)
+
+ if err != nil {
+ t.Fatalf("Serialization failed:%s", err)
+ }
+
+ if !id.VerifyObject(o) {
+ t.Errorf("Verification failed")
+ }
+}