X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Ftest.qc;h=23b0327683f15ba7f744a4edb64ae35dd8e89b53;hb=f1a87492d9fed27a64d0e99c068705aba5509f26;hp=3929bf1c3893cbd48433b6df03821dc4bbd4d7f1;hpb=d3e642e032c1e9e62fc5400c14627c54e37e4ae0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/test.qc b/qcsrc/lib/test.qc index 3929bf1c3..23b032768 100644 --- a/qcsrc/lib/test.qc +++ b/qcsrc/lib/test.qc @@ -1,7 +1,7 @@ #include "test.qh" -float TEST_failed; -float TEST_ok; +int TEST_failed; +bool TEST_ok; void TEST_Fail(string cond) { @@ -15,42 +15,37 @@ void TEST_OK() TEST_ok = true; } -float TEST_RunAll() +int TEST_RunAll_accumulated(int init); +bool 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; - } + int f = TEST_RunAll_accumulated(0); if (f) { LOG_INFOF("%d tests failed\n", f); - return 1; + return true; } else { - LOG_INFOF("All tests OK\n", f); - return 0; + LOG_INFO("All tests OK\n"); + return false; } } -float TEST_Run(string s) +bool TEST_Run(string s) { LOG_INFOF("%s: testing...\n", s); - TEST_failed = TEST_ok = 0; + TEST_failed = 0; + TEST_ok = false; callfunction(strcat("_TEST_", s)); if (TEST_failed > 0) { LOG_INFOF("%s: %d items failed.\n", s, TEST_failed); - return 0; + return false; } else if (!TEST_ok) { LOG_INFOF("%s: did not complete.\n", s); - return 0; + return false; } - return 1; + return true; }