Move test to /lib
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 23:40:54 +0000 (09:40 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 26 Aug 2015 23:40:54 +0000 (09:40 +1000)
qcsrc/client/progs.src
qcsrc/common/command/generic.qc
qcsrc/common/test.qc [deleted file]
qcsrc/common/test.qh [deleted file]
qcsrc/lib/_all.inc
qcsrc/lib/test.qc [new file with mode: 0644]
qcsrc/lib/test.qh [new file with mode: 0644]
qcsrc/menu/menu.qh
qcsrc/menu/progs.src
qcsrc/server/mutators/mutators_include.qc
qcsrc/server/progs.src

index 3c6ccc1..1b5471b 100644 (file)
@@ -52,7 +52,6 @@ weapons/projectile.qc // TODO
 ../common/physics.qc
 ../common/playerstats.qc
 ../common/p2mathlib.qc
-../common/test.qc
 ../common/util.qc
 
 ../common/viewloc.qc
index d12cc06..14bc589 100644 (file)
@@ -5,7 +5,6 @@
 #include "rpn.qh"
 
 #include "../mapinfo.qh"
-#include "../test.qh"
 
 #ifndef MENUQC
        #include "../notifications.qh"
diff --git a/qcsrc/common/test.qc b/qcsrc/common/test.qc
deleted file mode 100644 (file)
index 966553b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#if defined(CSQC)
-       #include "../dpdefs/csprogsdefs.qh"
-       #include "test.qh"
-#elif defined(MENUQC)
-#elif defined(SVQC)
-       #include "../dpdefs/dpextensions.qh"
-    #include "test.qh"
-#endif
-
-float TEST_failed;
-float TEST_ok;
-
-void TEST_Fail(string cond)
-{
-       printf("Assertion failed: ", cond);
-       //backtrace();
-       ++TEST_failed;
-}
-
-void TEST_OK()
-{
-       TEST_ok = true;
-}
-
-float TEST_RunAll()
-{
-       int f = 0;
-       float n = numentityfields();
-       for(int i = 0; i < n; ++i)
-       {
-               string name = entityfieldname(i);
-               if(substring(name, 0, 6) == "_TEST_")
-                       if(!TEST_Run(substring(name, 6, -1)))
-                               ++f;
-       }
-       if(f)
-       {
-               printf("%d tests failed\n", f);
-               return 1;
-       }
-       else
-       {
-               printf("All tests OK\n", f);
-               return 0;
-       }
-}
-
-float TEST_Run(string s)
-{
-       printf("%s: testing...\n", s);
-       TEST_failed = TEST_ok = 0;
-       callfunction(strcat("_TEST_", s));
-       if(TEST_failed > 0)
-       {
-               printf("%s: %d items failed.\n", s, TEST_failed);
-               return 0;
-       }
-       else if(!TEST_ok)
-       {
-               printf("%s: did not complete.\n", s);
-               return 0;
-       }
-       return 1;
-}
diff --git a/qcsrc/common/test.qh b/qcsrc/common/test.qh
deleted file mode 100644 (file)
index edc2f5b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef TEST_H
-#define TEST_H
-
-#define TEST_Check(cond) do { if(!(cond)) TEST_Fail(#cond); } while(0)
-
-void TEST_OK();
-void TEST_Fail(string cond);
-
-float TEST_RunAll();
-float TEST_Run(string test);
-#endif
index 1e7b85f..5a55b53 100644 (file)
@@ -7,4 +7,5 @@
 #include "OO.qh"
 #include "Progname.qh"
 #include "Registry.qh"
+#include "test.qc"
 #include "urllib.qc"
diff --git a/qcsrc/lib/test.qc b/qcsrc/lib/test.qc
new file mode 100644 (file)
index 0000000..04f9f68
--- /dev/null
@@ -0,0 +1,57 @@
+#include "test.qh"
+
+float TEST_failed;
+float TEST_ok;
+
+void TEST_Fail(string cond)
+{
+       printf("Assertion failed: ", cond);
+       //backtrace();
+       ++TEST_failed;
+}
+
+void TEST_OK()
+{
+       TEST_ok = true;
+}
+
+float TEST_RunAll()
+{
+       int f = 0;
+       float n = numentityfields();
+       for(int i = 0; i < n; ++i)
+       {
+               string name = entityfieldname(i);
+               if(substring(name, 0, 6) == "_TEST_")
+                       if(!TEST_Run(substring(name, 6, -1)))
+                               ++f;
+       }
+       if(f)
+       {
+               printf("%d tests failed\n", f);
+               return 1;
+       }
+       else
+       {
+               printf("All tests OK\n", f);
+               return 0;
+       }
+}
+
+float TEST_Run(string s)
+{
+       printf("%s: testing...\n", s);
+       TEST_failed = TEST_ok = 0;
+       callfunction(strcat("_TEST_", s));
+       if(TEST_failed > 0)
+       {
+               printf("%s: %d items failed.\n", s, TEST_failed);
+               return 0;
+       }
+       else if(!TEST_ok)
+       {
+               printf("%s: did not complete.\n", s);
+               return 0;
+       }
+       return 1;
+}
diff --git a/qcsrc/lib/test.qh b/qcsrc/lib/test.qh
new file mode 100644 (file)
index 0000000..d1f5357
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include "../common/util.qh"
+
+#define TEST_Check(cond) do { if(!(cond)) TEST_Fail(#cond); } while(0)
+
+void TEST_OK();
+void TEST_Fail(string cond);
+
+float TEST_RunAll();
+float TEST_Run(string test);
+#endif
index 020a65a..e4f594f 100644 (file)
@@ -9,7 +9,6 @@
 #include "xonotic/util.qh"
 
 #include "../common/constants.qh"
-#include "../common/test.qh"
 #include "../common/util.qh"
 
 #define localcmd cmd
index 4192c69..600e326 100644 (file)
@@ -20,7 +20,6 @@ xonotic/util.qc
 ../common/campaign_setup.qc
 ../common/mapinfo.qc
 ../common/playerstats.qc
-../common/test.qc
 ../common/util.qc
 
 ../common/items/all.qc
index a703fdc..c5b1ce2 100644 (file)
@@ -14,7 +14,6 @@
     #include "../../common/util.qh"
     #include "../../common/nades.qh"
     #include "../../common/buffs.qh"
-    #include "../../common/test.qh"
     #include "../../common/command/markup.qh"
     #include "../../common/command/rpn.qh"
     #include "../../common/command/generic.qh"
index 0cf64ca..61ec761 100644 (file)
@@ -99,7 +99,6 @@ weapons/weaponsystem.qc
 ../common/physics.qc
 ../common/playerstats.qc
 ../common/p2mathlib.qc
-../common/test.qc
 ../common/viewloc.qc
 ../common/triggers/include.qc
 ../common/util.qc