Changed arrays to use {} when converted to string; added tests
parent
5f7a8dbd5d
commit
c304ecd0ca
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue