コード例 #1
0
func TestNativeProxySequenceClaimExtrinsics(t *testing.T) {
	regMin := complex(-1, -1)
	regMax := complex(1, 1)

	planeMin := complex(-2, -2)
	planeMax := complex(2, 2)

	const picWidth uint = 100
	const picHeight uint = 100

	planeDim := planeMax - planeMin
	planeWidth := real(planeDim)
	planeHeight := imag(planeDim)

	uq := nativebase.UnitQuery{picWidth, picHeight, planeWidth, planeHeight}
	rUnit, iUnit := uq.PixelUnits()

	numerics := nativesequence.NativeSequenceNumerics{
		NativeBaseNumerics: nativebase.NativeBaseNumerics{
			SqrtDivergeLimit: sqrtDLimit,
			BaseNumerics: base.BaseNumerics{
				PicXMin: 0,
				PicYMin: 0,
				PicXMax: int(picWidth),
				PicYMax: int(picHeight),
			},
			RealMin: real(planeMin),
			RealMax: real(planeMax),
			ImagMin: imag(planeMin),
			ImagMax: imag(planeMax),
			Runit:   rUnit,
			Iunit:   iUnit,
		},
	}
	native := NativeSequenceProxy{
		LocalRegion:            createNativeRegion(numerics.NativeBaseNumerics, regMin, regMax),
		NativeSequenceNumerics: &numerics,
	}

	native.ClaimExtrinsics()

	expect := base.BaseNumerics{
		PicXMin: 25,
		PicXMax: 75,
		PicYMin: 25,
		PicYMax: 75,
	}

	actual := native.NativeBaseNumerics.BaseNumerics

	if actual != expect {
		t.Error("Expected ", expect, "but received", actual)
	}
}
コード例 #2
0
func TestRect(t *testing.T) {
	const picSide = 2
	const planeSide = 2.0

	const left = -1
	const bottom = -1
	const right = left + planeSide
	const top = bottom + planeSide

	min := complex(left, bottom)
	max := complex(right, top)
	parent := nativebase.NativeBaseNumerics{
		BaseNumerics: base.BaseNumerics{
			PicXMin: 0,
			PicXMax: picSide,
			PicYMin: 0,
			PicYMax: picSide,
		},
		SqrtDivergeLimit: sqrtDLimit,
		RealMin:          left,
		RealMax:          right,
		ImagMin:          bottom,
		ImagMax:          top,
	}
	numerics := &NativeRegionNumerics{
		NativeBaseNumerics: parent,
	}
	numerics.Region = createNativeRegion(parent, min, max)

	uq := nativebase.UnitQuery{picSide, picSide, planeSide, planeSide}
	numerics.Runit, numerics.Iunit = uq.PixelUnits()

	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)
	}

}