Example #1
0
func TestMarshalMany(t *testing.T) {
	nte := func() *Event {
		e := NewEvent()
		for i := 0; i < randutil.IntRange(0, 10); i++ {
			e.Tags.Set(randutil.String(randutil.IntRange(1, 10), randutil.Alphanumeric), randutil.String(randutil.IntRange(1, 10), randutil.Alphanumeric))
		}
		e.Time = time.Now()

		e.Metric = rand.Float64()
		return e
	}

	for i := 0; i < 100000; i++ {
		e := nte()
		buff, err := e.MarshalBinary()
		if err != nil {
			t.Fatal(err)
		}

		ne := NewEvent()
		err = ne.UnmarshalBinary(buff)
		if err != nil {
			t.Fatal(err)
		}

		if ne.Tags.String() != e.Tags.String() {
			t.Fatal(e.Tags.String(), ne.Tags.String())
		}

	}

}
Example #2
0
func randStrs(count int) []string {
	b := make([]string, count)
	for i := 0; i < count; i++ {
		b[i] = randutil.AlphaString(randutil.IntRange(10, 20))
	}

	return b
}