Updating unit tests

This commit is contained in:
Alex Yatskov 2012-04-06 06:52:10 -07:00
parent e7d6f510bc
commit b0a99cf73b

View File

@ -33,8 +33,6 @@ using namespace metacall;
// Defines // Defines
// //
#define TEST_UNICODE
#define TEST_ANSI
#define TEST_C_STRING #define TEST_C_STRING
#define TEST_BASIC_STRING #define TEST_BASIC_STRING
@ -43,6 +41,8 @@ using namespace metacall;
// C string // C string
// //
#ifdef TEST_C_STRING
static void testCStringAnsi(const char str[]) { static void testCStringAnsi(const char str[]) {
printf("[testCStringAnsi]: '%s'\n", str); printf("[testCStringAnsi]: '%s'\n", str);
} }
@ -52,35 +52,29 @@ static void testCStringUnicode(const wchar_t str[]) {
} }
static void testCString(Binding* binding, Protocol* protocol) { static void testCString(Binding* binding, Protocol* protocol) {
#ifdef TEST_C_STRING
binding->bind(FPARAM(testCStringAnsi)); binding->bind(FPARAM(testCStringAnsi));
binding->bind(FPARAM(testCStringUnicode)); binding->bind(FPARAM(testCStringUnicode));
#ifdef TEST_ANSI const char* stringsAnsi[] = { "Hello world", "", NULL };
{ for (int i = 0; i < 3; ++i) {
const char* strings[] = { "Hello world", "", NULL }; protocol->invoke("testCStringAnsi", stringsAnsi[i]);
for (int i = 0; i < 3; ++i) {
protocol->invoke("testCStringAnsi", strings[i]);
}
} }
#endif
#ifdef TEST_UNICODE const wchar_t* stringsUnicode[] = { L"Hello world", L"", NULL };
{ for (int i = 0; i < 3; ++i) {
const wchar_t* strings[] = { L"Hello world", L"", NULL }; protocol->invoke("testCStringUnicode", stringsUnicode[i]);
for (int i = 0; i < 3; ++i) {
protocol->invoke("testCStringUnicode", strings[i]);
}
} }
#endif
#endif
} }
#endif
// //
// std::basic_string // std::basic_string
// //
#ifdef TEST_BASIC_STRING
static void testBasicStringAnsi(const std::string& str) { static void testBasicStringAnsi(const std::string& str) {
printf("[testBasicStringAnsi]: '%s'\n", str.c_str()); printf("[testBasicStringAnsi]: '%s'\n", str.c_str());
} }
@ -90,30 +84,22 @@ static void testBasicStringUnicode(const std::wstring& str) {
} }
static void testBasicString(Binding* binding, Protocol* protocol) { static void testBasicString(Binding* binding, Protocol* protocol) {
#ifdef TEST_BASIC_STRING
binding->bind(FPARAM(testBasicStringAnsi)); binding->bind(FPARAM(testBasicStringAnsi));
binding->bind(FPARAM(testBasicStringUnicode)); binding->bind(FPARAM(testBasicStringUnicode));
#ifdef TEST_ANSI std::string stringsAnsi[] = { std::string("Hello world"), std::string() };
{ for (int i = 0; i < 2; ++i) {
std::string strings[] = { std::string("Hello world"), std::string() }; protocol->invoke("testBasicStringAnsi", stringsAnsi[i]);
for (int i = 0; i < 2; ++i) {
protocol->invoke("testBasicStringAnsi", strings[i]);
}
} }
#endif
#ifdef TEST_UNICODE std::wstring stringsUnicode[] = { std::wstring(L"Hello world"), std::wstring() };
{ for (int i = 0; i < 2; ++i) {
std::wstring strings[] = { std::wstring(L"Hello world"), std::wstring() }; protocol->invoke("testBasicStringUnicode", stringsUnicode[i]);
for (int i = 0; i < 2; ++i) {
protocol->invoke("testBasicStringUnicode", strings[i]);
}
} }
#endif
#endif
} }
#endif
// //
@ -139,8 +125,13 @@ int main(int, char *[]) {
Protocol& protocol = client.protocol(); Protocol& protocol = client.protocol();
do { do {
#ifdef TEST_C_STRING
testCString(&binding, &protocol); testCString(&binding, &protocol);
#endif
#ifdef TEST_BASIC_STRING
testBasicString(&binding, &protocol); testBasicString(&binding, &protocol);
#endif
server.advance(); server.advance();
client.advance(); client.advance();