Exemplo n.º 1
0
func BenchmarkZBox2_1M(b *testing.B) {
	b.StopTimer()
	p := makeTestString2(1000000)
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		core.PrecalcZboxes(p)
	}
}
Exemplo n.º 2
0
func BenchmarkZBox3_100k(b *testing.B) {
	b.StopTimer()
	p := makeTestString3(100000, 255)
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		core.PrecalcZboxes(p)
	}
}
Exemplo n.º 3
0
func ZBoxSpec(c gospec.Context) {
	c.Specify("Comprehensive test 3^9", func() {
		p := make([]byte, 9)
		for augment(p, 3) {
			c.Expect(core.PrecalcZboxes(p), ContainsExactly, idiotZboxer(p))
		}
	})
	c.Specify("Comprehensive test 2^15", func() {
		p := make([]byte, 15)
		for augment(p, 2) {
			c.Expect(core.PrecalcZboxes(p), ContainsExactly, idiotZboxer(p))
		}
	})
	c.Specify("Basic test.", func() {
		p := ""
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "a"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "abcabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aaabcabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcaabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcaaabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcaaaabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcaaaabc*aabcaaaabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabcaaaabc*aabcaaaabc*aabcaaaabc*aabcaaaabc*aabcaaaabc"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "abcdefghijklmnopq"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "abcdefghijklmnopqabcdefghijklmnopqabcdefghijklmnopq"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "abcdefghijklmnopqabc efghijklmnopqab cdefghijklmnopq"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aaaaaaaaaaaaaaaaaa"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "bbbbbbbbbbbaaaaaaaaaaaa"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "bbbbbbbaaaaaaaaabbbbbbbbbbbbbbaaaabbbbbbbbbaaaaabbaaaaaaaaabbaa"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
		p = "aabbaaa"
		c.Expect(core.PrecalcZboxes([]byte(p)), ContainsExactly, idiotZboxer([]byte(p)))
	})
}