summaryrefslogtreecommitdiff
path: root/testdata/scad/misc
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/scad/misc')
-rw-r--r--testdata/scad/misc/search-tests.scad63
-rw-r--r--testdata/scad/misc/vector-values.scad40
2 files changed, 103 insertions, 0 deletions
diff --git a/testdata/scad/misc/search-tests.scad b/testdata/scad/misc/search-tests.scad
new file mode 100644
index 0000000..fb85109
--- /dev/null
+++ b/testdata/scad/misc/search-tests.scad
@@ -0,0 +1,63 @@
+// string searches
+
+simpleSearch1=search("a","abcdabcd");
+echo(str("Characters in string (\"a\"): ",simpleSearch1));
+
+simpleSearch2=search("adeq","abcdeabcd",0);
+echo(str("Characters in string (\"adeq\"): ",simpleSearch2));
+
+sTable1=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9] ];
+s1= search("abe",sTable1);
+echo(str("Default string search (\"abe\"): ",s1));
+
+sTable2=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9],["a",10],["a",11] ];
+s2= search("abe",sTable2,0);
+echo(str("Return all matches for string search (\"abe\"): ",s2));
+
+sTable3=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9],["a",10],["a",11] ];
+s3= search("abe",sTable3,2);
+echo(str("Return up to 2 matches for string search (\"abe\"): ",s3));
+
+sTable4=[ [1,"a",[20]],[2,"b",21],[3,"c",22],[4,"d",23],[5,"a",24],[6,"b",25],[7,"c",26],[8,"d",27],[9,"e",28],[10,"a",29],[11,"a",30] ];
+s4= search("aebe",sTable4,2,1);
+echo(str("Return up to 2 matches for string search; alternate columns (\"aebe\"): ",s4));
+
+// s5= search("abe",sTable4,2,1,3); // bounds checking needs fixing.
+// echo(str("Return up to 2 matches for string search; alternate columns: ",s4));
+
+
+// number searches
+nTable1=[ [1,"a"],[3,"b"],[2,"c"],[4,"d"],[1,"a"],[7,"b"],[2,"c"],[8,"d"],[9,"e"],[10,"a"],[1,"a"] ];
+n1 = search(7,nTable1);
+echo(str("Default number search (7): ",n1));
+n2 = search(1,nTable1,0);
+echo(str("Return all matches for number search (1): ",n2));
+n3 = search(1,nTable1,2);
+echo(str("Return up to 2 matches for number search (1): ",n3));
+
+// list searches
+lTable1=[ [1,"a"],[3,"b"],[2,"c"],[4,"d"],[1,"a"],[7,"b"],[2,"c"],[8,"d"],[9,"e"],[10,"a"],[1,"a"] ];
+lSearch1=[1,3,1000];
+l1=search(lSearch1,lTable1);
+echo(str("Default list number search (",lSearch1,"): ",l1));
+
+lTable2=[ ["cat",1],["b",2],["c",3],["dog",4],["a",5],["b",6],["c",7],["d",8],["e",9],["apple",10],["a",11] ];
+lSearch2=["b","zzz","a","c","apple","dog"];
+l2=search(lSearch2,lTable2);
+echo(str("Default list string search (",lSearch2,"): ",l2));
+
+lTable3=[ ["cat",1],["b",2],["c",3],[4,"dog"],["a",5],["b",6],["c",7],["d",8],["e",9],["apple",10],["a",11] ];
+lSearch3=["b",4,"zzz","c","apple",500,"a",""];
+l3=search(lSearch3,lTable3);
+echo(str("Default list mixed search (",lSearch3,"): ",l3));
+
+l4=search(lSearch3,lTable3,0);
+echo(str("Return all matches for mixed search (",lSearch3,"): ",l4));
+
+lSearch5=[1,"zz","dog",500,11];
+l5=search(lSearch5,lTable3,0,1);
+echo(str("Return all matches for mixed search; alternate columns (",lSearch5,"): ",l5));
+
+
+// for completeness
+cube(1.0);
diff --git a/testdata/scad/misc/vector-values.scad b/testdata/scad/misc/vector-values.scad
new file mode 100644
index 0000000..1872b39
--- /dev/null
+++ b/testdata/scad/misc/vector-values.scad
@@ -0,0 +1,40 @@
+// Value vector tests.
+
+a1=[0,1,2];
+b1=[3,4,5];
+c1=a1*b1;
+echo(str("Testing vector dot product: ",c1));
+
+d1=[1,0];
+echo(str(" Bounds check: ",a1*d1));
+
+m2=[[0,1],[1,0]];
+v2=[2,3];
+p2=m2*v2;
+echo(str("Testing matrix * vector: ",p2));
+
+d2=[0,0,1];
+echo(str(" Bounds check: ",m2*d2));
+
+m3=[[1,-1,1],[1,0,-1]];
+v3=[1,1];
+p3=v3*m3;
+echo(str("Testing vector * matrix: ",p3));
+
+echo(str(" Bounds check: ",m3*v3));
+
+ma4=[ [1,0],[0,1] ];
+mb4=[ [1,0],[0,1] ];
+echo(str("Testing id matrix * id matrix: ",ma4*mb4));
+
+ma5=[ [1, 0, 1]
+ ,[0, 1,-1] ];
+mb5=[ [1,0]
+ ,[0,1]
+ ,[1,1] ];
+echo(str("Testing asymmetric matrix * matrix: ",ma5*mb5));
+echo(str("Testing alternate asymmetric matrix * matrix: ",mb5*ma5));
+
+echo(str(" Bounds check: ",ma5*ma4));
+
+cube(1.0);
contact: Jan Huwald // Impressum