[colobot] 200/377: More CBot tests

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 5b7638d9f48aa6230e4f55c0349b40f2aafd554c
Author: krzys-h <krzys_h at interia.pl>
Date:   Fri Dec 25 14:46:39 2015 +0100

    More CBot tests
---
 test/unit/CBot/CBot.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 104 insertions(+), 4 deletions(-)

diff --git a/test/unit/CBot/CBot.cpp b/test/unit/CBot/CBot.cpp
index 040904e..3596441 100644
--- a/test/unit/CBot/CBot.cpp
+++ b/test/unit/CBot/CBot.cpp
@@ -389,6 +389,44 @@ TEST_F(CBotUT, BasicOperations)
     );
 }
 
+TEST_F(CBotUT, VarBasic)
+{
+    ExecuteTest(
+        "extern void VarBasic()\n"
+        "{\n"
+        "    int a = 5;\n"
+        "    ASSERT(a == 5);\n"
+        "    int b = 3;\n"
+        "    ASSERT(b == 3);\n"
+        "    b = a;\n"
+        "    ASSERT(b == 5);\n"
+        "    ASSERT(b == a);\n"
+        "    b = a + b;\n"
+        "    ASSERT(b == 10);\n"
+        "    ASSERT(b == 2*a);\n"
+        "}\n"
+    );
+}
+
+TEST_F(CBotUT, VarDefinitions)
+{
+    ExecuteTest(
+        "extern void TestUndefined()\n"
+        "{\n"
+        "    ASSERT(a == 0);\n"
+        "}\n",
+        CBotErrUndefVar
+    );
+    ExecuteTest(
+        "extern void TestRedefined()\n"
+        "{\n"
+        "    int a = 5;\n"
+        "    int a = 3;\n"
+        "}\n",
+        CBotErrRedefVar
+    );
+}
+
 TEST_F(CBotUT, Functions)
 {
     ExecuteTest(
@@ -439,21 +477,38 @@ TEST_F(CBotUT, FunctionRecursionStackOverflow)
 TEST_F(CBotUT, FunctionOverloading)
 {
     ExecuteTest(
-        "void func(int test)\n"
+        "int func(string test)\n"
         "{\n"
-        "    FAIL();\n"
+        "    return 1;\n"
         "}\n"
-        "void func(string test)\n"
+        "int func(int test)\n"
         "{\n"
+        "    return 2;\n"
         "}\n"
         "\n"
         "extern void FunctionOverloading()\n"
         "{\n"
-        "    func(\"5\");\n"
+        "    ASSERT(func(\"5\") == 1);\n"
+        "    ASSERT(func(5) == 2);\n"
         "}\n"
     );
 }
 
+TEST_F(CBotUT, FunctionRedefined)
+{
+    ExecuteTest(
+        "int func(int test)\n"
+        "{\n"
+        "    return 1;\n"
+        "}\n"
+        "int func(int test)\n"
+        "{\n"
+        "    return 2;\n"
+        "}\n",
+        CBotErrRedefFunc
+    );
+}
+
 TEST_F(CBotUT, ClassConstructor)
 {
     ExecuteTest(
@@ -526,3 +581,48 @@ TEST_F(CBotUT, DISABLED_ClassDestructorNaming)
         static_cast<CBotError>(-1)
     );
 }
+
+// TODO: This doesn't work
+TEST_F(CBotUT, DISABLED_ClassMethodOverloading)
+{
+    ExecuteTest(
+        "public class TestClass {\n"
+        "    public int test(string test) {\n"
+        "        return 1;\n"
+        "    }\n"
+        "    public int test(int test) {\n"
+        "        return 2;"
+        "    }\n"
+        "}\n"
+        "extern void ClassMethodOverloading() {\n"
+        "    TestClass t();\n"
+        "    ASSERT(t.test(\"5\") == 1);\n"
+        "    ASSERT(t.test(5) == 2);\n"
+        "}\n"
+    );
+}
+
+TEST_F(CBotUT, ClassMethodRedefined)
+{
+    ExecuteTest(
+        "public class TestClass {\n"
+        "    public int test(string test) {\n"
+        "        return 1;\n"
+        "    }\n"
+        "    public int test(string test) {\n"
+        "        return 2;"
+        "    }\n"
+        "}\n",
+        CBotErrRedefFunc
+    );
+}
+
+// TODO: Not only doesn't work but segfaults
+TEST_F(CBotUT, DISABLED_ClassRedefined)
+{
+    ExecuteTest(
+        "public class TestClass {}\n"
+        "public class TestClass {}\n",
+        CBotErrRedefClass
+    );
+}
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list