1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#include "CoreSuite.h"
#include "TestTest.h"
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestTest,
coreSuiteName() );
TestTest::TestTest() :
CPPUNIT_NS::TestFixture()
{
}
TestTest::~TestTest()
{
}
void
TestTest::setUp()
{
m_suite = new CPPUNIT_NS::TestSuite( "suite" );
m_test1 = new MockTestCase( "test1" );
m_test2 = new MockTestCase( "test2" );
m_suite->addTest( m_test1 );
m_suite->addTest( m_test2 );
m_path = new CPPUNIT_NS::TestPath();
}
void
TestTest::tearDown()
{
delete m_suite;
delete m_path;
}
void
TestTest::testFindTestPathPointerThis()
{
CPPUNIT_ASSERT( m_test1->findTestPath( m_test1, *m_path ) );
CPPUNIT_ASSERT_EQUAL( 1, m_path->getTestCount() );
CPPUNIT_ASSERT( m_test1 == m_path->getChildTest() );
m_path->removeTests();
CPPUNIT_ASSERT( m_suite->findTestPath( m_suite, *m_path ) );
CPPUNIT_ASSERT_EQUAL( 1, m_path->getTestCount() );
CPPUNIT_ASSERT( m_suite == m_path->getChildTest() );
}
void
TestTest::testFindTestPathPointer()
{
CPPUNIT_ASSERT( m_suite->findTestPath( m_test1, *m_path ) );
CPPUNIT_ASSERT_EQUAL( 2, m_path->getTestCount() );
CPPUNIT_ASSERT( m_suite == m_path->getTestAt(0) );
CPPUNIT_ASSERT( m_test1 == m_path->getTestAt(1) );
}
void
TestTest::testFindTestPathPointerFail()
{
MockTestCase test( "test" );
CPPUNIT_ASSERT( !m_suite->findTestPath( &test, *m_path ) );
CPPUNIT_ASSERT( !m_path->isValid() );
}
void
TestTest::testFindTestPathNameThis()
{
CPPUNIT_ASSERT( m_test1->findTestPath( "test1", *m_path ) );
CPPUNIT_ASSERT_EQUAL( 1, m_path->getTestCount() );
CPPUNIT_ASSERT( m_test1 == m_path->getChildTest() );
m_path->removeTests();
CPPUNIT_ASSERT( m_suite->findTestPath( "suite", *m_path ) );
CPPUNIT_ASSERT_EQUAL( 1, m_path->getTestCount() );
CPPUNIT_ASSERT( m_suite == m_path->getChildTest() );
}
void
TestTest::testFindTestPathName()
{
CPPUNIT_ASSERT( m_suite->findTestPath( "test2", *m_path ) );
CPPUNIT_ASSERT_EQUAL( 2, m_path->getTestCount() );
CPPUNIT_ASSERT( m_suite == m_path->getTestAt(0) );
CPPUNIT_ASSERT( m_test2 == m_path->getTestAt(1) );
}
void
TestTest::testFindTestPathNameFail()
{
CPPUNIT_ASSERT( !m_suite->findTestPath( "bad-test", *m_path ) );
CPPUNIT_ASSERT( !m_path->isValid() );
}
void
TestTest::testFindTest()
{
CPPUNIT_ASSERT( m_test1 == m_suite->findTest( "test1" ) );
}
void
TestTest::testFindTestThrow()
{
m_suite->findTest( "no-name" );
}
void
TestTest::testResolveTestPath()
{
CPPUNIT_NS::TestPath path1 = m_suite->resolveTestPath( "suite");
CPPUNIT_ASSERT_EQUAL( 1, path1.getTestCount() );
CPPUNIT_ASSERT( m_suite == path1.getTestAt(0) );
CPPUNIT_NS::TestPath path2 = m_suite->resolveTestPath( "suite/test2");
CPPUNIT_ASSERT_EQUAL( 2, path2.getTestCount() );
CPPUNIT_ASSERT( m_suite == path2.getTestAt(0) );
CPPUNIT_ASSERT( m_test2 == path2.getTestAt(1) );
}
|