void TestTwine008Cast_ToXmlChar() { BEGIN_TEST_METHOD( "TestTwine008Cast_ToXmlChar" ) twine t1 = "12345678901234567890"; twine t2 = "Something that will be longer than our 32 byte inner buffer size"; // Simple assignment should work for small strings const char* c1 = t1(); const xmlChar* c2 = t1; ASSERT_EQUALS( (xmlChar*)c1, c2, "t1() != (const xmlChar*)t1"); // Simple assignment should work for large strings c1 = t2(); c2 = t2; ASSERT_EQUALS( (xmlChar*)c1, c2, "t2() != (const xmlChar*)t2"); // When small strings become large strings, everything should still work: t1 += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 20 + 26 = 46, which is > 32. c1 = t1(); c2 = t1; ASSERT_EQUALS( (xmlChar*)c1, c2, "t1() != (const xmlChar*)t1"); END_TEST_METHOD }
void TestTwine006Convert_ToFloat() { BEGIN_TEST_METHOD( "TestTwine006Convert_ToFloat" ) twine t1 = "1.1"; twine t2 = "12.345"; twine t3 = "456.789"; ASSERT_EQUALS( (float)1.1, t1.get_float(), "1.1 != t1.get_float()" ); ASSERT_EQUALS( (float)12.345, t2.get_float(), "12.345 != t2.get_float()" ); ASSERT_EQUALS( (float)456.789, t3.get_float(), "456.789 != t3.get_float()" ); END_TEST_METHOD }
void TestTwine006Convert_ToDouble() { BEGIN_TEST_METHOD( "TestTwine006Convert_ToDouble" ) twine t1 = "1.1"; twine t2 = "12.345"; twine t3 = "456.789"; ASSERT_EQUALS( 1.1, t1.get_double(), "1.1 != t1.get_double()" ); ASSERT_EQUALS( 12.345, t2.get_double(), "12.345 != t2.get_double()" ); ASSERT_EQUALS( 456.789, t3.get_double(), "456.789 != t3.get_double()" ); END_TEST_METHOD }
void TestTwine006Convert_ToInt() { BEGIN_TEST_METHOD( "TestTwine006Convert_ToInt" ) twine t1 = "1"; twine t2 = "12345"; twine t3 = "456789"; ASSERT_EQUALS( 1, t1.get_int(), "1 != t1.get_int()" ); ASSERT_EQUALS( 12345, t2.get_int(), "12345 != t2.get_int()" ); ASSERT_EQUALS( 456789, t3.get_int(), "456789 != t3.get_int()" ); END_TEST_METHOD }
void TestTwine009Compare_EndsWith() { BEGIN_TEST_METHOD( "TestTwine009Compare_EndsWith" ) twine empty1; const char* empty2 = NULL; twine short1 = "Something Short"; const char* short2 = "Something Short"; twine long1 = "Something A Bit Longer that Will cause us to allocate memory"; const char* long2 = "Something A Bit Longer that Will cause us to allocate memory"; ASSERT_EXCEPTION( empty1.endsWith( empty2 ), "empty1.endsWith( empty2 ) should cause exception"); ASSERT_FALSE( empty1.endsWith( short1 ), "empty1.endsWith( short1 ) == true"); ASSERT_FALSE( empty1.endsWith( short2 ), "empty1.endsWith( short2 ) == true"); ASSERT_FALSE( empty1.endsWith( long1 ), "empty1.endsWith( long1 ) == true"); ASSERT_FALSE( empty1.endsWith( long2 ), "empty1.endsWith( long2 ) == true"); ASSERT_TRUE( short1.endsWith( short2 ), "short1.endsWith( short2 ) == false"); ASSERT_TRUE( short1.endsWith( "Short" ), "short1.endsWith( 'Short' ) == false"); ASSERT_TRUE( short1.endsWith( "t" ), "short1.endsWith( 't' ) == false"); ASSERT_TRUE( short1.endsWith( "hort" ), "short1.endsWith( 'hort' ) == false"); ASSERT_EXCEPTION( short1.endsWith( (char*)NULL ), "short1.endsWith( NULL ) should cause exception"); ASSERT_FALSE( short1.endsWith( empty1 ), "short1.endsWith( empty1 ) == true"); ASSERT_EXCEPTION( short1.endsWith( empty2 ), "short1.endsWith( empty2 ) should cause exception"); ASSERT_FALSE( short1.endsWith( long1 ), "short1.endsWith( long1 ) == true"); ASSERT_FALSE( short1.endsWith( long2 ), "short1.endsWith( long2 ) == true"); ASSERT_TRUE( long1.endsWith( long2 ), "long1.endsWith( long2 ) == false"); ASSERT_TRUE( long1.endsWith( "allocate memory" ), "long1.endsWith( 'allocate memory' ) == false"); ASSERT_TRUE( long1.endsWith( "memory" ), "long1.endsWith( 'memory' ) == false"); ASSERT_TRUE( long1.endsWith( "y" ), "long1.endsWith( 'y' ) == false"); ASSERT_EXCEPTION( long1.endsWith( (char*)NULL ), "long1.endsWith( NULL ) should cause exception"); ASSERT_FALSE( long1.endsWith( empty1 ), "long1.endsWith( empty1 ) == true"); ASSERT_EXCEPTION( long1.endsWith( empty2 ), "long1.endsWith( empty2 ) should cause exception"); ASSERT_FALSE( long1.endsWith( short1 ), "long1.endsWith( short1 ) == true"); ASSERT_FALSE( long1.endsWith( short2 ), "long1.endsWith( short2 ) == true"); END_TEST_METHOD }
void TestTwine009Compare_ToCharStar() { BEGIN_TEST_METHOD( "TestTwine009Compare_ToCharStar" ) twine empty1; const char* empty2 = NULL; twine short1 = "Something Short"; const char* short2 = "Something Short"; twine long1 = "Something A Bit Longer that Will cause us to allocate memory"; const char* long2 = "Something A Bit Longer that Will cause us to allocate memory"; // Ensure that everything has different data pointers: ASSERT_NOTEQUALS( empty1(), empty2, "empty1 and empty2 point to the same memory"); ASSERT_NOTEQUALS( short1(), short2, "short1 and short2 point to the same memory"); ASSERT_NOTEQUALS( long1(), long2, "long1 and long2 point to the same memory"); ASSERT_EQUALS( 0, empty1.compare( empty2 ), "empty1.compare( empty2 ) != 0"); ASSERT_NOTEQUALS( 0, empty1.compare( short1 ), "empty1.compare( short1 ) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( short2 ), "empty1.compare( short2 ) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( long1 ), "empty1.compare( long1) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( long2 ), "empty1.compare( long2) == 0"); ASSERT_EQUALS( 0, short1.compare( short2 ), "short1.compare( short2 ) != 0"); ASSERT_NOTEQUALS( 0, short1.compare( empty1 ), "short1.compare( empty1 ) == 0"); ASSERT_NOTEQUALS( 0, short1.compare( empty2), "short1.compare( empty2) == 0"); ASSERT_NOTEQUALS( 0, short1.compare( long1 ), "short1.compare( long1) == 0"); ASSERT_NOTEQUALS( 0, short1.compare( long2 ), "short1.compare( long2) == 0"); ASSERT_EQUALS( 0, long1.compare( long2 ), "long1.compare( long2 ) != 0"); ASSERT_NOTEQUALS( 0, long1.compare( empty1 ), "long1.compare( empty1 ) == 0"); ASSERT_NOTEQUALS( 0, long1.compare( empty2), "long1.compare( empty2) == 0"); ASSERT_NOTEQUALS( 0, long1.compare( short1 ), "long1.compare( short1) == 0"); ASSERT_NOTEQUALS( 0, long1.compare( short2 ), "long1.compare( short2) == 0"); END_TEST_METHOD }
void TestTwine009Compare_ToTwineCount() { BEGIN_TEST_METHOD( "TestTwine009Compare_ToTwineCount" ) twine empty1; twine empty2; twine short1 = "Something Short"; twine short2 = "Something Short"; twine long1 = "Something A Bit Longer that Will cause us to allocate memory"; twine long2 = "Something A Bit Longer that Will cause us to allocate memory"; // Ensure that everything has different data pointers: ASSERT_NOTEQUALS( empty1(), empty2(), "empty1 and empty2 point to the same memory"); ASSERT_NOTEQUALS( short1(), short2(), "short1 and short2 point to the same memory"); ASSERT_NOTEQUALS( long1(), long2(), "long1 and long2 point to the same memory"); ASSERT_EQUALS( 0, empty1.compare( empty2, 10 ), "empty1.compare( empty2, 10 ) != 0"); ASSERT_NOTEQUALS( 0, empty1.compare( short1, 10 ), "empty1.compare( short1, 10 ) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( short2, 10 ), "empty1.compare( short2, 10 ) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( long1, 10 ), "empty1.compare( long1, 10) == 0"); ASSERT_NOTEQUALS( 0, empty1.compare( long2, 10 ), "empty1.compare( long2, 10) == 0"); ASSERT_EQUALS( 0, short1.compare( short2, 10 ), "short1.compare( short2, 10 ) != 0"); ASSERT_NOTEQUALS( 0, short1.compare( empty1, 10 ), "short1.compare( empty1, 10 ) == 0"); ASSERT_NOTEQUALS( 0, short1.compare( empty2, 10), "short1.compare( empty2, 10) == 0"); ASSERT_EQUALS( 0, short1.compare( long1, 10 ), "short1.compare( long1, 10) != 0"); ASSERT_EQUALS( 0, short1.compare( long2, 10 ), "short1.compare( long2, 10) != 0"); ASSERT_EQUALS( 0, long1.compare( long2, 10 ), "long1.compare( long2, 10 ) != 0"); ASSERT_NOTEQUALS( 0, long1.compare( empty1, 10 ), "long1.compare( empty1, 10 ) == 0"); ASSERT_NOTEQUALS( 0, long1.compare( empty2, 10), "long1.compare( empty2, 10) == 0"); ASSERT_EQUALS( 0, long1.compare( short1, 10 ), "long1.compare( short1, 10) != 0"); ASSERT_EQUALS( 0, long1.compare( short2, 10 ), "long1.compare( short2, 10) != 0"); END_TEST_METHOD }
/* **************************************************************************** */ /* This is an SLib test that is included in our SLibTest application. This code */ /* is included directly in SLibTest.cpp, so there is no need for additional */ /* headers, etc. Refer to SLibTest.cpp for the global variables that you have */ /* access to. */ /* Please ensure that this test is declared properly in SLibTest.h, and invoked */ /* inside SLibTest.cpp in the RunOneTable method - or wherever appropriate. */ /* **************************************************************************** */ void TestDate002Copying() { BEGIN_TEST_METHOD( "TestDate002Copying" ) // Useful macros: // ASSERT_EQUALS(a, b, "a is not equal to b, but it should be.") // ASSERT_NOTEQUALS(a, b, "a is equal to b, but it shouldn't be.") // ASSERT_TRUE(a, "a should be true, but it isn't.") // ASSERT_FALSE(a, "a should be false, but it isn't.") END_TEST_METHOD }
// This class is intended to test: // GetConsoleAlias class AliasTests { BEGIN_TEST_CLASS(AliasTests) TEST_CLASS_PROPERTY(L"BinaryUnderTest", L"conhost.exe") TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"wincon.h") TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"winconp.h") TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"conmsgl1.h") TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"conmsgl3.h") TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"api-ms-win-core-console-l3-2-0.lib") END_TEST_CLASS() BEGIN_TEST_METHOD(TestGetConsoleAlias) TEST_METHOD_PROPERTY(L"Data:strSource", L"{g}") TEST_METHOD_PROPERTY(L"Data:strExpectedTarget", L"{cmd.exe /k echo foo}") TEST_METHOD_PROPERTY(L"Data:strExeName", L"{cmd.exe}") TEST_METHOD_PROPERTY(L"Data:dwSource", L"{0, 1}") TEST_METHOD_PROPERTY(L"Data:dwTarget", L"{0, 1, 2, 3, 4, 5, 6}") TEST_METHOD_PROPERTY(L"Data:dwExeName", L"{0, 1}") TEST_METHOD_PROPERTY(L"Data:bUnicode", L"{FALSE, TRUE}") TEST_METHOD_PROPERTY(L"Data:bSetFirst", L"{FALSE, TRUE}") END_TEST_METHOD() }; // Caller must free ppsz if not null. void ConvertWToA(_In_ PCWSTR pwsz, _Out_ char** ppsz) {
/* **************************************************************************** */ /* This is an SLib test that is included in our SLibTest application. This code */ /* is included directly in SLibTest.cpp, so there is no need for additional */ /* headers, etc. Refer to SLibTest.cpp for the global variables that you have */ /* access to. */ /* Please ensure that this test is declared properly in SLibTest.h, and invoked */ /* inside SLibTest.cpp in the RunOneTable method - or wherever appropriate. */ /* **************************************************************************** */ void TestDate003Updating() { BEGIN_TEST_METHOD( "TestDate003Updating" ) // Useful macros: // ASSERT_EQUALS(a, b, "a is not equal to b, but it should be.") // ASSERT_NOTEQUALS(a, b, "a is equal to b, but it shouldn't be.") // ASSERT_TRUE(a, "a should be true, but it isn't.") // ASSERT_FALSE(a, "a should be false, but it isn't.") END_TEST_METHOD }