Skip to content

Commit c417fda

Browse files
author
ANDO Yasushi
committed
add tests
1 parent b609562 commit c417fda

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mat4_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,26 @@ func TestMat4FromZRotation(t *testing.T) {
421421
}
422422
}
423423

424+
func TestMat4FromRotationTranslationScale(t *testing.T) {
425+
q := QuatFromValues(1, 0, 0, 0)
426+
v := Vec3FromValues(1, 2, 3)
427+
s := []float64{4, 5, 6}
428+
429+
actual := Mat4FromRotationTranslationScale(Mat4Create(), q, v, s)
430+
431+
transMat := Mat4Create()
432+
Mat4Identity(transMat)
433+
Mat4Translate(transMat, transMat, v)
434+
rotateMat := Mat4Create()
435+
rotateMat = Mat4FromQuat(rotateMat, q)
436+
expect := Mat4Multiply(Mat4Create(), transMat, rotateMat)
437+
Mat4Scale(expect, expect, s)
438+
439+
if !testSlice(actual, expect) {
440+
t.Errorf("from rotation, translation and scale: \n%v \n%v", actual, expect)
441+
}
442+
}
443+
424444
func TestMat4Str(t *testing.T) {
425445
actual := Mat4Str(mat4A)
426446
expect := "mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1)"

0 commit comments

Comments
 (0)