MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / TEST

Function TEST

Engine/source/console/test/engineAPITest.cpp:12–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12TEST(EngineAPI, EngineMarshallData)
13{
14 // Reserve some values
15 ConsoleValue values[16];
16 ConsoleValueRef refValues[16];
17
18 for (U32 i=0; i<16; i++)
19 {
20 values[i].init();
21 refValues[i].value = &values[i];
22 }
23
24 // Basic string casting...
25 SimObject *foo = new SimObject();
26 foo->registerObject();
27
28 const char *value = EngineMarshallData(foo);
29 EXPECT_TRUE(dStricmp(value, foo->getIdString()) == 0)
30 << "SimObject should be casted to its ID";
31
32 U32 unsignedNumber = 123;
33 S32 signedNumber = -123;
34 value = EngineMarshallData(unsignedNumber);
35 EXPECT_TRUE(dStricmp(value, "123") == 0)
36 << "Integer should be converted to 123";
37 value = EngineMarshallData(signedNumber);
38 EXPECT_TRUE(dStricmp(value, "-123") == 0)
39 << "Integer should be converted to -123";
40
41 bool boolValue = true;
42 value = EngineMarshallData(boolValue);
43 EXPECT_TRUE(dStricmp(value, "1") == 0)
44 << "Bool should be converted to 1";
45
46 Point3F point(1,2,3);
47 value = EngineMarshallData(point);
48 EXPECT_TRUE(dStricmp(value, "1 2 3") == 0)
49 << "Point3F should be converted to 1 2 3";
50
51 F32 floatValue = 1.23f;
52 value = EngineMarshallData(floatValue);
53 EXPECT_TRUE(dStricmp(value, "1.23") == 0)
54 << "F32 should be converted to 1.23";
55
56 // Argv based casting
57 S32 argc = 0;
58 EngineMarshallData(foo, argc, refValues);
59 EngineMarshallData((const SimObject*)foo, argc, refValues);
60 EngineMarshallData(point, argc, refValues);
61 EngineMarshallData(unsignedNumber, argc, refValues);
62 EngineMarshallData(signedNumber, argc, refValues);
63 EngineMarshallData(boolValue, argc, refValues);
64 EngineMarshallData(floatValue, argc, refValues);
65
66 EXPECT_TRUE(argc == 7)
67 << "7 args should have been set";
68
69 EXPECT_TRUE(values[0].type == ConsoleValue::TypeInternalInt && values[0].getSignedIntValue() == foo->getId())

Callers

nothing calls this directly

Calls 12

EngineMarshallDataFunction · 0.85
dStricmpFunction · 0.85
mRoundFunction · 0.85
evaluateFunction · 0.85
getIdStringMethod · 0.80
getIdMethod · 0.65
findObjectFunction · 0.50
initMethod · 0.45
registerObjectMethod · 0.45
getStringValueMethod · 0.45
getFloatValueMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected