#include "Utilities.h"
#ifdef _MSC_VER
# define SNPRINTF _snprintf
#else
# define SNPRINTF snprintf
#endif
void argCountTest()
{
int x0 = YQ_ARG_COUNT();
int x1 = YQ_ARG_COUNT(1);
int x2 = YQ_ARG_COUNT(1, 2);
int x3 = YQ_ARG_COUNT(1, 2, 3);
int x4 = YQ_ARG_COUNT(1, 2, 3, 4);
int x5 = YQ_ARG_COUNT(1, 2, 3, 4, 1);
int x6 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1);
int x7 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1, 1);
int x8 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1, 1, 1);
int x9 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1, 1, 1, 1);
int x10 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1, 1, 1, 1, 1);
int x11 = YQ_ARG_COUNT(1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1);
char buf[1024];
SNPRINTF(buf, 1024, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11);
yqConsolePrintString(buf);
}
void buildTypeTest()
{
if (BT_IsRelease)
{
yqConsolePrintString("Release build\n");
}
else
{
yqConsolePrintString("Debug build\n");
}
if (BT_IsDebug)
{
yqConsolePrintString("Debug build\n");
}
else
{
yqConsolePrintString("Release build\n");
}
}
struct POD_Test
{
PODString str;
int x, y, z;
};
struct nonPOD_Test
{
nonPOD_Test() { x = 1; y = 2; z = 3; }
int x, y, z;
};
void dynamicArrayTest()
{
// These 2 lines shouldn't be able to be compiled
//ArrayPOD<nonPOD_Test> nonPodArray1;
//PODArrayPOD<nonPOD_Test> nonPodArray2;
ArrayPOD<POD_Test> podArray1;
ArrayPOD<POD_Test> podArray2;
// These following line shouldn't be able to be compiled
//podArray2 = podArray1;
PODArrayPOD<POD_Test> podArray;
PODArrayPOD<POD_Test> podArray3;
podArray3 = podArray; // This is the problem with PODArrayPOD, you can do this assignment. ArrayPOD disallows this.
podArray.init();
podArray.reserve(100);
POD_Test a;
a.x = 0; a.y = 0;
podArray.push(a);
}
void stringTests()
{
std::string s1;
s1 = "Hello";
s1 += " World";
s1 += "!!!";
yqConsolePrintString(s1.c_str());
s1 = "Reset";
yqConsolePrintString(s1.c_str());
PODString s;
s.init();
s = "Hello";
s += " World";
s += "!!!";
yqConsolePrintString(s.c_str());
s = "Reset";
yqConsolePrintString(s.c_str());
s.deinit();
}
yqResult resTest1() { YQ_API_LEAVE(R_Failure); }
yqResult resTest2() { YQ_API_LEAVE(R_Failure, "Unimplemented"); }
yqResult resTest3() { YQ_API_LEAVE(R_Failure, "format %i", 1234); }
yqResult resTest4() { YQ_API_LEAVE(R_Okay, "All good"); }
yqResult resTest5() { YQ_API_LEAVE(R_Okay); }
void runTests()
{
stringTests();
resTest1();
resTest2();
resTest3();
resTest4();
resTest5();
argCountTest();
buildTypeTest();
dynamicArrayTest();
}