int main() { int numPlayers = 2; int kingdomCards[10] = {smithy, adventurer, gardens, embargo, great_hall, mine, ambassador, outpost, baron, tribute}; int randomSeed = 15; struct gameState state; int result = 0; int oldHandCount, newHandCount; int oldActionCount, newActionCount; printf("CARDTEST3: GREAT HALL\n"); initializeGame(numPlayers, kingdomCards, randomSeed, &state); oldHandCount = numHandCards(&state); oldActionCount = state.numActions; //int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus); //TEST GREAT HALL result = cardEffect(great_hall, 0, 0, 0, &state, 1, NULL); assertc(result, "Completely failed Great Hall"); newHandCount = numHandCards(&state); assertSame(oldHandCount, newHandCount, "Hand sizes aren't the same"); newActionCount = state.numActions; assertDiff(oldActionCount, newActionCount, "Actions didn't change"); if (newActionCount == oldActionCount + 1) { result = 0; } assertc(result, "Actions didn't increment by 1"); checkFail(); return 0; }
void test() { const Length_m len2000m(2000); const Length_m len2048m(2048); const Length_km len2km(2); const LengthDbl_km len2_048km(2.048); assertSame(len2000m); assertSame(len2048m); assertSame(len2km); assertSame(len2_048km); assertEqual(len2000m, len2km); assertEqual(len2048m, len2_048km); assertLess(len2000m, len2048m); assertLess(len2000m, len2_048km); assertLess(len2km, len2048m); assertLess(len2km, len2_048km); }
/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ static void assertSame(javolution::lang::Object const& expected, javolution::lang::Object const& actual) { assertSame(L"assertSame(javolution::lang::Object, javolution::lang::Object)", expected, actual); }
void TestSuite::TestString(void){ UnitTest::SetPrefix("TestString.cpp - Test String Class"); { json_string s; assertEmpty(s); } { json_string s; assertEmpty(s); json_string m(s); assertEmpty(m); assertEmpty(s); assertSame(s, m); } { json_string s(JSON_TEXT("hello")); assertEquals(s.length(), 5); assertFalse(s.empty()); assertCStringSame(s.c_str(), JSON_TEXT("hello")); assertEquals(s, s); assertEquals(s, JSON_TEXT("hello")); s.clear(); assertEmpty(s); } { json_string s(5, 'h'); assertEquals(s.length(), 5); assertFalse(s.empty()); assertCStringSame(s.c_str(), JSON_TEXT("hhhhh")); assertEquals(s, s); assertEquals(s, JSON_TEXT("hhhhh")); s.clear(); assertEmpty(s); } { json_string s(5, 'h'); json_string m(s); assertSame(s, m); } { json_string s(5, 'h'); json_string m(s); assertSame(s, m); s.clear(); assertEmpty(s); assertEquals(s.length(), 0); assertDifferent(s, m); } { json_string s(JSON_TEXT("hello")); json_string m = s; assertSame(s, m); m = s.substr(1, 3); assertEquals(m.length(), 3); assertEquals(m, JSON_TEXT("ell")); } { json_string s(JSON_TEXT("hello")); json_string m = s; assertSame(s, m); m = s.substr(1); assertEquals(m.length(), 4); assertEquals(m, JSON_TEXT("ello")); } { json_string s(JSON_TEXT("hello")); s += JSON_TEXT(" world"); assertEquals(s.length(), 11); assertEquals(s, JSON_TEXT("hello world")); } { json_string s(JSON_TEXT("hello")); json_string m = s + JSON_TEXT(" world ") + s; assertEquals(m.length(), 17); assertEquals(m, JSON_TEXT("hello world hello")); } { json_string s(JSON_TEXT("hello")); s += 'a'; s += 'a'; s += 'a'; s += 'a'; assertEquals(s.length(), 9); assertEquals(s, JSON_TEXT("helloaaaa")); } { json_string s(JSON_TEXT("hello world")); size_t pos = s.find('w'); assertEquals(pos, 6); } { json_string s(JSON_TEXT("hello world")); size_t pos = s.find('z'); assertEquals(pos, json_string::npos); } { json_string s(JSON_TEXT("hello world")); size_t pos = s.find_first_not_of(JSON_TEXT("helo")); assertEquals(pos, 5); } { json_string s(JSON_TEXT("hello world")); size_t pos = s.find_first_of(JSON_TEXT("ol")); assertEquals(pos, 2); } { json_string s(JSON_TEXT("hello world")); s.erase(s.begin(), s.begin() + 3); assertEquals(s, JSON_TEXT("lo world")); } { json_string s(JSON_TEXT("hello world"), 5); assertEquals(s, JSON_TEXT("hello")); } #ifndef JSON_STRING_HEADER { json_string s(JSON_TEXT("hello world")); std::wstring wtest(L"hello world"); std::string stest("hello world"); assertEquals(libjson::to_std_string(s), stest); assertEquals(stest, libjson::to_std_string(s)); assertEquals(libjson::to_std_wstring(s), wtest); assertEquals(wtest, libjson::to_std_wstring(s)); assertEquals(s, libjson::to_json_string(stest)); assertEquals(libjson::to_json_string(stest), s); assertEquals(s, libjson::to_json_string(wtest)); assertEquals(libjson::to_json_string(wtest), s); } #endif }