doc: paulchen beispiele {code{a,b},gesamt} entpackt (jedes mal entpacken nervt langsa...
[uebersetzerbau-ss10.git] / aus_sammelwut / paulchen / ublu / ss08 / abgabe / codeb / .svn / text-base / test.c.svn-base
diff --git a/aus_sammelwut/paulchen/ublu/ss08/abgabe/codeb/.svn/text-base/test.c.svn-base b/aus_sammelwut/paulchen/ublu/ss08/abgabe/codeb/.svn/text-base/test.c.svn-base
new file mode 100644 (file)
index 0000000..6052e59
--- /dev/null
@@ -0,0 +1,187 @@
+#include <stdio.h>
+
+extern long f1(long a);
+extern long f2(long a);
+extern long f3(long a);
+extern long f4(long a);
+extern long f5(long a);
+extern long f6(long a);
+extern long f7(long a);
+extern long f8(long a);
+extern long f9(long a);
+extern long f10(long a);
+
+extern long g1(long a, long b);
+extern long g2(long a, long b);
+extern long g3(long a, long b);
+extern long g4(long a, long b);
+extern long g5(long a, long b);
+extern long g6(long a, long b);
+extern long g7(long a, long b);
+extern long g8(long a, long b);
+extern long g9(long a, long b);
+extern long g10(long a, long b);
+extern long g11(long a, long b);
+extern long g12(long a, long b);
+
+extern long h1(long a, long b, long c, long d);
+extern long h2(long a, long b, long c, long d);
+extern long h3(long a, long b, long c, long d);
+extern long h4(long a, long b, long c, long d);
+extern long h5(long a, long b, long c, long d);
+extern long h6(long a, long b, long c, long d);
+extern long h7(long a, long b, long c, long d);
+extern long h8(long a, long b, long c, long d);
+extern long h9(long a, long b, long c, long d);
+extern long h10(long a, long b, long c, long d);
+extern long h11(long a, long b, long c, long d);
+extern long h12(long a, long b, long c, long d);
+extern long h13(long a, long b, long c, long d);
+extern long h14(long a, long b, long c, long d);
+extern long h15(long a, long b, long c, long d);
+extern long h16(long a, long b, long c, long d);
+extern long h17(long a, long b, long c, long d);
+extern long h18(long a, long b, long c, long d);
+extern long h19(long a, long b, long c, long d);
+extern long h20(long a, long b, long c, long d);
+extern long h21(long a, long b, long c, long d);
+extern long h22(long a, long b, long c, long d);
+extern long h23(long a, long b, long c, long d);
+extern long h24(long a, long b, long c, long d);
+
+int check_arg1(char *name, long (*function)(long), long ret0, long ret1, long ret2) {
+       int ret;
+       ret=function(0)==ret0 && function(1)==ret1 && function(2)==ret2;
+       printf("%s: %li/%li, %li/%li, %li/%li - %s\n", name,function(0), ret0, function(1), ret1, function(2), ret2, ret ? "ok" : "FAIL");
+       return ret;
+}
+
+int check_arg2(char *name, long (*function)(long, long), long blubb[2][2]) {
+       int ret,a,b;
+       ret=1;
+       printf("%s - ", name);
+       for(a=0;a<2;a++) {
+               for(b=0;b<2;b++) {
+                       ret&=(function(a,b)==blubb[a][b]);
+                       printf("%li/%li ", function(a,b),blubb[a][b]);
+               }
+       }
+       printf("- %s\n", ret ? "ok" : "FAIL");
+       return ret;
+}
+
+int check_arg4(char *name, long (*function)(long, long, long, long), long blubb[2][2][2][2]) {
+       int ret,a,b,c,d;
+       ret=1;
+       printf("%s - ", name);
+       for(a=0;a<2;a++) {
+               for(b=0;b<2;b++) {
+                       for(c=0;c<2;c++) {
+                               for(d=0;d<2;d++) {
+                                       ret&=(function(a,b,c,d)==blubb[a][b][c][d]);
+                                       printf("%li/%li ", function(a,b,c,d),blubb[a][b][c][d]);
+                               }
+                       }
+               }
+       }
+       printf("- %s\n", ret ? "ok" : "FAIL");
+       return ret;
+}
+
+int main(int argc, char **argv) {
+       int ret;
+
+       long ret_g1[2][2]={{1,1},{1,0}};
+       long ret_g2[2][2]={{1,0},{1,1}};
+       long ret_g3[2][2]={{1,1},{0,1}};
+       long ret_g4[2][2]={{0,1},{1,1}};
+       long ret_g5[2][2]={{0,0},{0,1}};
+       long ret_g6[2][2]={{0,1},{0,0}};
+       long ret_g7[2][2]={{0,0},{1,0}};
+       long ret_g8[2][2]={{1,0},{0,0}};
+       long ret_g9[2][2]={{1,1},{1,0}};
+       long ret_g10[2][2]={{1,0},{1,1}};
+       long ret_g11[2][2]={{1,1},{0,1}};
+       long ret_g12[2][2]={{0,1},{1,1}};
+
+       long ret_h1[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,0}}}};
+       long ret_h2[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,0}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+       long ret_h3[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,0}},{{1,1},{1,1}}}};
+       long ret_h4[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,0},{1,1}}}};
+       long ret_h5[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{0,1}}}};
+
+       long ret_h6[2][2][2][2]={{{{1,1},{1,0}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+       long ret_h7[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{0,1},{1,1}}}};
+       long ret_h8[2][2][2][2]={{{{0,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+
+       long ret_h9[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{0,0},{0,1}}}};
+       long ret_h10[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,1}}},{{{0,0},{0,0}},{{0,0},{0,0}}}};
+       long ret_h11[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,1}},{{0,0},{0,0}}}};
+       long ret_h12[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{0,1},{0,0}}}};
+       long ret_h13[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{0,0},{1,0}}}};
+       long ret_h14[2][2][2][2]={{{{0,0},{0,1}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{0,0},{0,0}}}};
+       long ret_h15[2][2][2][2]={{{{0,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{1,0},{0,0}}}};
+       long ret_h16[2][2][2][2]={{{{1,0},{0,0}},{{0,0},{0,0}}},{{{0,0},{0,0}},{{0,0},{0,0}}}};
+
+       long ret_h17[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,0}}}};
+       long ret_h18[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,0}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+       long ret_h19[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,0}},{{1,1},{1,1}}}};
+       long ret_h20[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,0},{1,1}}}};
+       long ret_h21[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{0,1}}}};
+
+       long ret_h22[2][2][2][2]={{{{1,1},{1,0}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+       long ret_h23[2][2][2][2]={{{{1,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{0,1},{1,1}}}};
+       long ret_h24[2][2][2][2]={{{{0,1},{1,1}},{{1,1},{1,1}}},{{{1,1},{1,1}},{{1,1},{1,1}}}};
+
+       ret=check_arg1("f1",f1,0,1,1);
+       ret&=check_arg1("f2",f2,0,0,1);
+       ret&=check_arg1("f3",f3,1,0,0);
+       ret&=check_arg1("f4",f4,0,1,1);
+       ret&=check_arg1("f5",f5,0,0,1);
+       ret&=check_arg1("f6",f6,1,0,0);
+       ret&=check_arg1("f7",f7,0,1,1);
+       ret&=check_arg1("f8",f8,0,0,1);
+       ret&=check_arg1("f9",f9,1,1,1);
+       ret&=check_arg1("f10",f10,1,0,0);
+
+       ret&=check_arg2("g1",g1,ret_g1);
+       ret&=check_arg2("g2",g2,ret_g2);
+       ret&=check_arg2("g3",g3,ret_g3);
+       ret&=check_arg2("g4",g4,ret_g4);
+       ret&=check_arg2("g5",g5,ret_g5);
+       ret&=check_arg2("g6",g6,ret_g6);
+       ret&=check_arg2("g7",g7,ret_g7);
+       ret&=check_arg2("g8",g8,ret_g8);
+       ret&=check_arg2("g9",g9,ret_g9);
+       ret&=check_arg2("g10",g10,ret_g10);
+       ret&=check_arg2("g11",g11,ret_g11);
+       ret&=check_arg2("g12",g12,ret_g12);
+
+       ret&=check_arg4("h1",h1,ret_h1);
+       ret&=check_arg4("h2",h2,ret_h2);
+       ret&=check_arg4("h3",h3,ret_h3);
+       ret&=check_arg4("h4",h4,ret_h4);
+       ret&=check_arg4("h5",h5,ret_h5);
+       ret&=check_arg4("h6",h6,ret_h6);
+       ret&=check_arg4("h7",h7,ret_h7);
+       ret&=check_arg4("h8",h8,ret_h8);
+       ret&=check_arg4("h9",h9,ret_h9);
+       ret&=check_arg4("h10",h10,ret_h10);
+       ret&=check_arg4("h11",h11,ret_h11);
+       ret&=check_arg4("h12",h12,ret_h12);
+       ret&=check_arg4("h13",h13,ret_h13);
+       ret&=check_arg4("h14",h14,ret_h14);
+       ret&=check_arg4("h15",h15,ret_h15);
+       ret&=check_arg4("h16",h16,ret_h16);
+       ret&=check_arg4("h17",h17,ret_h17);
+       ret&=check_arg4("h18",h18,ret_h18);
+       ret&=check_arg4("h19",h19,ret_h19);
+       ret&=check_arg4("h20",h20,ret_h20);
+       ret&=check_arg4("h21",h21,ret_h21);
+       ret&=check_arg4("h22",h22,ret_h22);
+       ret&=check_arg4("h23",h23,ret_h23);
+       ret&=check_arg4("h24",h24,ret_h24);
+
+       return !ret;
+}
+