Browse Source

Tests: Update getInverse() unit tests.

Mugen87 5 years ago
parent
commit
f03084ef34
2 changed files with 8 additions and 32 deletions
  1. 5 18
      test/unit/src/math/Matrix3.tests.js
  2. 3 14
      test/unit/src/math/Matrix4.tests.js

+ 5 - 18
test/unit/src/math/Matrix3.tests.js

@@ -6,7 +6,6 @@
 
 
 import { Matrix3 } from '../../../../src/math/Matrix3';
 import { Matrix3 } from '../../../../src/math/Matrix3';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Matrix4 } from '../../../../src/math/Matrix4';
-import { Float32BufferAttribute } from '../../../../src/core/BufferAttribute';
 
 
 function matrixEquals3( a, b, tolerance ) {
 function matrixEquals3( a, b, tolerance ) {
 
 
@@ -260,25 +259,13 @@ export default QUnit.module( 'Maths', () => {
 
 
 		QUnit.test( "getInverse", ( assert ) => {
 		QUnit.test( "getInverse", ( assert ) => {
 
 
-			var identity = new Matrix3();
+			var zero = new Matrix3().set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
 			var identity4 = new Matrix4();
 			var identity4 = new Matrix4();
-			var a = new Matrix3();
-			var b = new Matrix3().set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
-			var c = new Matrix3().set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
-
-			b.getInverse( a, false );
-			assert.ok( matrixEquals3( a, identity ), "Matrix a is identity matrix" );
-
-			try {
-
-				b.getInverse( c, true );
-				assert.ok( false, "Should never get here !" ); // should never get here.
-
-			} catch ( err ) {
-
-				assert.ok( true, "Passed: " + err );
+			var a = new Matrix3().set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+			var b = new Matrix3();
 
 
-			}
+			b.getInverse( a );
+			assert.ok( matrixEquals3( b, zero ), "Matrix a is zero matrix" );
 
 
 			var testMatrices = [
 			var testMatrices = [
 				new Matrix4().makeRotationX( 0.3 ),
 				new Matrix4().makeRotationX( 0.3 ),

+ 3 - 14
test/unit/src/math/Matrix4.tests.js

@@ -461,26 +461,15 @@ export default QUnit.module( 'Maths', () => {
 
 
 		QUnit.test( "getInverse", ( assert ) => {
 		QUnit.test( "getInverse", ( assert ) => {
 
 
+			var zero = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
 			var identity = new Matrix4();
 			var identity = new Matrix4();
 
 
 			var a = new Matrix4();
 			var a = new Matrix4();
 			var b = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
 			var b = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
-			var c = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
 
 
-			assert.ok( ! matrixEquals4( a, b ), "Passed!" );
-			b.getInverse( a, false );
-			assert.ok( matrixEquals4( b, new Matrix4() ), "Passed!" );
-
-			try {
-
-				b.getInverse( c, true );
-				assert.ok( false, "Passed!" ); // should never get here.
+			a.getInverse( b );
+			assert.ok( matrixEquals4( a, zero ), "Passed!" );
 
 
-			} catch ( err ) {
-
-				assert.ok( true, "Passed!" );
-
-			}
 
 
 			var testMatrices = [
 			var testMatrices = [
 				new Matrix4().makeRotationX( 0.3 ),
 				new Matrix4().makeRotationX( 0.3 ),