Exemplo n.º 1
0
func CMWCSpec(c gospec.Context) {
	c.Specify("CMWC32 produces the same output as SlowCMWC.", func() {
		fast := core.MakeCMWC32(11, 4)
		slow := core.MakeSlowCMWC(11, 1<<32, 1<<4)
		N := 100000
		for i := 0; i < N; i++ {
			f := fast.Next()
			s := slow.Next()
			c.Expect(f, Equals, s)
			if f != s {
				break
			}
		}
	})
}
Exemplo n.º 2
0
func SlowCMWCSpec(c gospec.Context) {
	c.Specify("SlowCMWC produces sequences with the expected period.", func() {
		c.Specify("(A, B, R, Period) = (3, 16, 2, 96)", func() {
			gen := core.MakeSlowCMWC(3, 16, 2)
			period := core.Check(gen, 500)
			c.Expect(period, Equals, 96)
		})
		c.Specify("(A, B, R, Period) = (13, 16, 2, 416)", func() {
			gen := core.MakeSlowCMWC(13, 16, 2)
			period := core.Check(gen, 500)
			c.Expect(period, Equals, 416)
		})
		c.Specify("(A, B, R, Period) = (37, 256, 2, 128)", func() {
			gen := core.MakeSlowCMWC(37, 256, 2)
			period := core.Check(gen, 500)
			c.Expect(period, Equals, 128)
		})
		c.Specify("(A, B, R, Period) = (103, 256, 2, 52736)", func() {
			gen := core.MakeSlowCMWC(103, 256, 2)
			period := core.Check(gen, 100000)
			c.Expect(period, Equals, 52736)
		})
	})
}