Bug fix: test

This commit is contained in:
Hajime Hoshi 2013-06-19 09:33:26 +09:00
parent 7c23c6b326
commit 45c59133ef
2 changed files with 17 additions and 17 deletions

View File

@ -5,7 +5,7 @@ import (
. "."
)
func setElements(matrix *AffineMatrix, elements [][]AffineMatrixElement) {
func setElements(matrix *AffineMatrix, elements [][]float64) {
dimension := len(elements) + 1
for i := 0; i < dimension-1; i++ {
for j := 0; j < dimension; j++ {
@ -19,7 +19,7 @@ func TestAffineMatrixElement(t *testing.T) {
matrix.SetElement(0, 0, 1)
matrix.SetElement(0, 1, 2)
matrix.SetElement(0, 2, 3)
expected := [][]AffineMatrixElement{
expected := [][]float64{
{1, 2, 3, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
@ -39,7 +39,7 @@ func TestAffineMatrixElement(t *testing.T) {
matrix.SetElement(1, 0, 4)
matrix.SetElement(1, 1, 5)
matrix.SetElement(2, 3, 6)
expected = [][]AffineMatrixElement{
expected = [][]float64{
{1, 2, 3, 0},
{4, 5, 0, 0},
{0, 0, 0, 6},
@ -86,18 +86,18 @@ func TestAffineMatrixIsIdentity(t *testing.T) {
func TestAffineMatrixConcat(t *testing.T) {
matrix1 := IdentityAffineMatrix(3)
matrix2 := IdentityAffineMatrix(3)
setElements(matrix1, [][]AffineMatrixElement{
setElements(matrix1, [][]float64{
{2, 0, 0},
{0, 2, 0},
})
setElements(matrix2, [][]AffineMatrixElement{
setElements(matrix2, [][]float64{
{1, 0, 1},
{0, 1, 1},
})
// TODO: 'matrix1x2' may not be a good name.
matrix1x2 := matrix1.Concat(matrix2)
expected := [][]AffineMatrixElement{
expected := [][]float64{
{2, 0, 1},
{0, 2, 1},
{0, 0, 1},
@ -114,7 +114,7 @@ func TestAffineMatrixConcat(t *testing.T) {
}
matrix2x1 := matrix2.Concat(matrix1)
expected = [][]AffineMatrixElement{
expected = [][]float64{
{2, 0, 2},
{0, 2, 2},
{0, 0, 1},
@ -132,19 +132,19 @@ func TestAffineMatrixConcat(t *testing.T) {
matrix3 := NewAffineMatrix(4)
matrix4 := NewAffineMatrix(4)
setElements(matrix3, [][]AffineMatrixElement{
setElements(matrix3, [][]float64{
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
})
setElements(matrix4, [][]AffineMatrixElement{
setElements(matrix4, [][]float64{
{13, 14, 15, 16},
{17, 18, 19, 20},
{21, 22, 23, 24},
})
matrix3x4 := matrix3.Concat(matrix4)
expected = [][]AffineMatrixElement{
expected = [][]float64{
{218, 260, 302, 360},
{278, 332, 386, 460},
{338, 404, 470, 560},
@ -161,7 +161,7 @@ func TestAffineMatrixConcat(t *testing.T) {
}
matrix4x3 := matrix4.Concat(matrix3)
expected = [][]AffineMatrixElement{
expected = [][]float64{
{110, 116, 122, 132},
{314, 332, 350, 376},
{518, 548, 578, 620},

View File

@ -15,37 +15,37 @@ func TestGeometryMatrixElements(t *testing.T) {
matrix.SetTy(6)
got := matrix.A()
want := AffineMatrixElement(1)
want := float64(1)
if want != got {
t.Errorf("matrix.A() = %f, want %f", got, want)
}
got = matrix.B()
want = AffineMatrixElement(2)
want = float64(2)
if want != got {
t.Errorf("matrix.B() = %f, want %f", got, want)
}
got = matrix.C()
want = AffineMatrixElement(3)
want = float64(3)
if want != got {
t.Errorf("matrix.C() = %f, want %f", got, want)
}
got = matrix.D()
want = AffineMatrixElement(4)
want = float64(4)
if want != got {
t.Errorf("matrix.D() = %f, want %f", got, want)
}
got = matrix.Tx()
want = AffineMatrixElement(5)
want = float64(5)
if want != got {
t.Errorf("matrix.Tx() = %f, want %f", got, want)
}
got = matrix.Ty()
want = AffineMatrixElement(6)
want = float64(6)
if want != got {
t.Errorf("matrix.Ty() = %f, want %f", got, want)
}