func TestBigMandelbrotSequence(t *testing.T) {
	const prec = 53
	const iterLimit = 10

	app := &bigbase.MockRenderApplication{
		MockRenderApplication: base.MockRenderApplication{
			Base: base.BaseConfig{
				DivergeLimit: 4.0,
			},
			PictureWidth:  10,
			PictureHeight: 10,
		},
	}
	app.UserMin = bigbase.MakeBigComplex(0.0, 0.0, prec)
	app.UserMax = bigbase.MakeBigComplex(10.0, 10.0, prec)
	numerics := Make(app)
	out := numerics.Sequence()

	const expectedCount = 100
	actualCount := len(out)

	if expectedCount != actualCount {
		t.Error("Expected", expectedCount, "members but there were", actualCount)
	}
}
Ejemplo n.º 2
0
func TestRect(t *testing.T) {
	left := -1.0
	bottom := -1.0
	right := 1.0
	top := 1.0

	app := &MockRenderApplication{}
	app.UserMin = bigbase.MakeBigComplex(left, bottom, prec)
	app.UserMax = bigbase.MakeBigComplex(right, top, prec)
	app.Prec = 53
	app.PictureWidth = 2
	app.PictureHeight = 2

	numerics := Make(app)

	expectMinX := 0
	expectMaxX := 2
	expectMinY := 0
	expectMaxY := 2

	r := numerics.Rect()

	okay := expectMinX == r.Min.X
	okay = okay && expectMaxX == r.Max.X
	okay = okay && expectMinY == r.Min.Y
	okay = okay && expectMaxY == r.Max.Y
	if !okay {
		t.Error("Rectangle had unexpected bounds", r)
	}
}
func TestBigProxySequenceClaimExtrinsics(t *testing.T) {
	const picW = 100
	const picH = 100

	app := &bigbase.MockRenderApplication{}
	app.PictureWidth = picW
	app.PictureHeight = picH
	app.UserMin = bigbase.MakeBigComplex(-2.0, -2.0, prec)
	app.UserMax = bigbase.MakeBigComplex(2.0, 2.0, prec)
	app.Prec = prec

	numerics := bigsequence.Make(app)

	min := bigbase.MakeBigComplex(-1.0, -1.0, prec)
	max := bigbase.MakeBigComplex(1.0, 1.0, prec)
	region := createBigRegion(numerics.BigBaseNumerics, min, max)

	bsnp := BigSequenceNumericsProxy{
		BigSequenceNumerics: &numerics,
		LocalRegion:         region,
	}

	bsnp.ClaimExtrinsics()

	expect := base.BaseNumerics{
		WholeWidth:  picW,
		WholeHeight: picH,
		PicXMin:     25,
		PicXMax:     75,
		PicYMin:     25,
		PicYMax:     75,
	}

	actual := bsnp.BigBaseNumerics.BaseNumerics

	if actual != expect {
		t.Error("Expected ", expect, "but received", actual)
	}
}
Ejemplo n.º 4
0
func TestSampleDivs(t *testing.T) {
	const pWidth = 100
	const pHeight = 100
	const iLimit = 255
	const dLimit = 1.42
	const maxRegSz = 10
	const samples = 100
	const natMin = complex(-2.0, -2.0)
	const natMax = complex(2.0, 2.0)
	const prec = 53

	bigMin := bigbase.MakeBigComplex(real(natMin), imag(natMax), prec)
	bigMax := bigbase.MakeBigComplex(real(natMax), imag(natMax), prec)

	mockBase := base.MockRenderApplication{}
	mockBase.PictureWidth = pWidth
	mockBase.PictureHeight = pHeight
	mockBase.Base.IterateLimit = iLimit
	mockBase.Base.DivergeLimit = dLimit
	mockBase.Base.FixAspect = true

	regConfig := region.RegionConfig{}
	regConfig.CollapseSize = maxRegSz
	regConfig.Samples = samples

	bigCoords := bigbase.MockBigCoordProvider{}
	bigCoords.UserMin = bigMin
	bigCoords.UserMax = bigMax
	bigCoords.Prec = prec

	// This business is over complicated
	bigProvider := region.MockRegionProvider{}
	bigProvider.RegConfig = regConfig
	bigProvider.RegionFactory = fRegFactory(func() region.RegionNumerics {
		app := &MockRenderApplication{}
		app.MockRegionProvider = bigProvider
		app.MockRenderApplication = mockBase
		app.MockBigCoordProvider = bigCoords
		bignums := Make(app)
		return &bignums
	})

	nativeCoords := nativebase.MockNativeCoordProvider{}
	nativeCoords.PlaneMin = natMin
	nativeCoords.PlaneMax = natMax

	nativeProvider := region.MockRegionProvider{}
	nativeProvider.RegConfig = regConfig
	nativeProvider.RegionFactory = fRegFactory(func() region.RegionNumerics {
		app := &nativeregion.MockRenderApplication{}
		app.MockNativeCoordProvider = nativeCoords
		app.MockRegionProvider = nativeProvider
		app.MockRenderApplication = mockBase
		natnums := nativeregion.Make(app)
		return &natnums
	})

	bReg := bigProvider.RegionFactory.Build()
	nReg := bigProvider.RegionFactory.Build()

	bich, _ := bReg.SampleDivs()
	nich, _ := nReg.SampleDivs()
	bs := slurp(bich)
	ns := slurp(nich)

	for i, bInvDiv := range bs {
		nInvDiv := ns[i]
		if bInvDiv != nInvDiv {
			t.Error("Mismatch InvDiv at sample ", i,
				"native was", nInvDiv, "but big was", bInvDiv)
		}
	}
}