[colobot] 122/145: Changed arrays to use {} when converted to string; added tests
Didier Raboud
odyx at moszumanska.debian.org
Mon Jul 11 12:56:24 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 c304ecd0cab9b62670d384d8ae93d9ab66c4d1fc
Author: krzys-h <krzys_h at interia.pl>
Date: Tue Jun 21 12:58:43 2016 +0200
Changed arrays to use {} when converted to string; added tests
---
src/CBot/CBotVar/CBotVarClass.cpp | 7 +++++--
test/unit/CBot/CBot_test.cpp | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp
index 919b43a..08acffb 100644
--- a/src/CBot/CBotVar/CBotVarClass.cpp
+++ b/src/CBot/CBotVar/CBotVarClass.cpp
@@ -343,10 +343,12 @@ std::string CBotVarClass::GetValString()
res += " (";
}
}
+
+ res += " )";
}
else
{
- res = "( ";
+ res = "{ ";
CBotVar* pv = m_pVar;
while ( pv != nullptr )
@@ -355,9 +357,10 @@ std::string CBotVarClass::GetValString()
if ( pv->GetNext() != nullptr ) res += ", ";
pv = pv->GetNext();
}
+
+ res += " }";
}
- res += " )";
return res;
}
diff --git a/test/unit/CBot/CBot_test.cpp b/test/unit/CBot/CBot_test.cpp
index e8cdcd1..c0d5e12 100644
--- a/test/unit/CBot/CBot_test.cpp
+++ b/test/unit/CBot/CBot_test.cpp
@@ -485,6 +485,30 @@ TEST_F(CBotUT, VarImplicitCast)
);
}
+TEST_F(CBotUT, ToString)
+{
+ ExecuteTest(
+ "extern void ArrayToString()\n"
+ "{\n"
+ " int[] array = {2, 4, 6};\n"
+ " string arrayStr = \"\"+array;\n"
+ " ASSERT(arrayStr == \"{ 2, 4, 6 }\");\n"
+ "}\n"
+ );
+
+ ExecuteTest(
+ "public class Test { int a = 1337; }\n"
+ "extern void ClassToString()\n"
+ "{\n"
+ " Test test();\n"
+ " string testStr = \"\"+test;\n"
+ " ASSERT(testStr == \"Pointer to Test( a=1337 )\");\n"
+ "}\n"
+ );
+
+ // TODO: IntrinsicClassToString ? (e.g. point)
+}
+
TEST_F(CBotUT, Arrays)
{
ExecuteTest(
--
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