Example #1
0
func TestReaderUUID(t *testing.T) {
	b := new(bytes.Buffer)
	writer := NewWriter(b)
	u := uuid.Parse("3f257da1-0b85-48d6-8f5c-6cd13d2d60c9")
	writer.Serialize(&u)
	writer.Serialize(&u)
	writer.Serialize(&u)
	if b.String() != "g{3f257da1-0b85-48d6-8f5c-6cd13d2d60c9}r0;r0;" {
		t.Error(b.String())
	}
	var u2, u3 *uuid.UUID
	reader := NewReader(b)
	if err := reader.Unserialize(&u); err != nil {
		t.Error(err.Error())
	}
	if err := reader.Unserialize(&u2); err != nil {
		t.Error(err.Error())
	}
	if err := reader.Unserialize(&u3); err != nil {
		t.Error(err.Error())
	}
	if u2 != u3 {
		t.Error(u, u2, u3)
	}
}
func TestSimpleWriterUUID(t *testing.T) {
	b := new(bytes.Buffer)
	writer := NewSimpleWriter(b)
	err := writer.Serialize(uuid.Parse("3f257da1-0b85-48d6-8f5c-6cd13d2d60c9"))
	if err != nil {
		t.Error(err.Error())
	}
	if b.String() != "g{3f257da1-0b85-48d6-8f5c-6cd13d2d60c9}" {
		t.Error(b.String())
	}
}