diff yetilab/matrix/test/test_matrix.yeti @ 158:b6db07468ed1

Rework stream to support indefinite-length streams and handle multiple channels in framer. Make compile, but some tests fail (and others are still missing).
author Chris Cannam
date Wed, 01 May 2013 12:03:45 +0100
parents 4e52d04887a5
children a9d58d9c71ca
line wrap: on
line diff
--- a/yetilab/matrix/test/test_matrix.yeti	Wed May 01 07:58:39 2013 +0100
+++ b/yetilab/matrix/test/test_matrix.yeti	Wed May 01 12:03:45 2013 +0100
@@ -6,15 +6,9 @@
 
 import yeti.lang: FailureException;
 
-{ compare } = load yetilab.test.test;
+{ compare, compareUsing } = load yetilab.test.test;
 
-compareMatrices obtained expected =
-    if mat.equal obtained expected then
-        true;
-    else
-        println "** expected: \(expected.data)\n   obtained: \(obtained.data)";
-        false;
-    fi;
+compareMatrices = compareUsing mat.equal;
 
 makeTests name flipper =
    (constMatrix n s = flipper (mat.constMatrix n s);
@@ -229,6 +223,27 @@
     yrt
 ),
 
+"resizedTo-\(name)": \(
+    compareMatrices
+       (mat.resizedTo { rows = 2, columns = 2 }
+           (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]))
+       (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]) and
+        compareMatrices
+           (mat.resizedTo { rows = 3, columns = 4 }
+               (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]))
+           (newMatrix (ColumnMajor ()) [[1,4,0],[2,5,0],[3,6,0],[0,0,0]]) and
+        compareMatrices
+           (mat.resizedTo { rows = 1, columns = 1 }
+               (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]))
+           (newMatrix (ColumnMajor ()) [[1]])
+),
+
+"zeroSizeMatrix-\(name)": \(
+    compareMatrices
+       (mat.zeroSizeMatrix ())
+       (newMatrix (ColumnMajor ()) [])
+),
+
 ]);
 
 colhash = makeTests "column-major" id;