コード例 #1
0
 TestList
 createDummies ()
   {
     TestList list;
     list.push_back (DD<1>());
     list.push_back (DD<3>());
     list.push_back (DD<5>());
     list.push_back (DD<7>());
     return list;
   } //note: copy
コード例 #2
0
 TestList
 createOpaqueValues ()
   {
     TestList list;
     list.push_back (PolyVal::build<Imp<1>>  () );
     list.push_back (PolyVal::build<Imp<11>> () );
     list.push_back (PolyVal::build<Imp<111>>() );
     list.push_back (PolyVal::build<Imp<23>> () );
     list.push_back (PolyVal::build<Imp<5>>  () );
     return list;
   } //note: copy
コード例 #3
0
ファイル: test.cpp プロジェクト: sourcey/libsourcey
ErrorMap TestRunner::errors() const
{
    ErrorMap errors;
    TestList tests = this->tests();
    for (auto it = tests.begin(); it != tests.end(); ++it) {
        if (!(*it)->passed()) {
            errors[(*it)] = (*it)->errors;
        }
    }
    return errors;
}
コード例 #4
0
ファイル: UnitTest.cpp プロジェクト: DaiLiRong/rippled
UnitTests::TestList UnitTests::selectStartupTests (TestList const& tests) const noexcept
{
    TestList list;
    for (int i = 0; i < tests.size(); ++i)
    {
        UnitTest* const test = tests [i];
        if (test->getWhen () == UnitTest::runStartup)
            list.add (test);
    }
    return list;
}
コード例 #5
0
 void operator()( TestList& list ) const
 {
     list.sort();
     
     gTestController.CancelFailureCountdown();
     
     for ( TestList::iterator p = list.begin(); p != list.end(); p++ )
         if ( p != list.begin() ) {
             TestList::iterator tmp=p;
             --tmp;
             EH_ASSERT( *p >= *tmp );
         }
 }
コード例 #6
0
ファイル: UnitTest.cpp プロジェクト: DaiLiRong/rippled
UnitTests::TestList UnitTests::selectPackage (
    String const& package, TestList const& tests) const noexcept
{
    TestList list;
    list.ensureStorageAllocated (tests.size ());
    for (int i = 0; i < tests.size(); ++i)
    {
        UnitTest* const test = tests [i];
        if (package.equalsIgnoreCase (test->getPackageName ()) &&
            test->getWhen () != UnitTest::runManual)
            list.add (test);
    }
    return list;
}
コード例 #7
0
ファイル: UnitTest.cpp プロジェクト: DaiLiRong/rippled
UnitTests::TestList UnitTests::selectTest (
    String const& testname, TestList const& tests) const noexcept
{
    TestList list;
    for (int i = 0; i < tests.size(); ++i)
    {
        UnitTest* const test = tests [i];
        if (testname.equalsIgnoreCase (test->getClassName ()))
        {
            list.add (test);
            break;
        }
    }
    return list;
}
コード例 #8
0
int RunAllTests(TestReporter& reporter, TestList const& list, int const maxTestTimeInMs )
{
    TestResults result(&reporter);

    Timer overallTimer;
    overallTimer.Start();

    Test const* curTest = list.GetHead();
    while (curTest != 0)
    {
        Timer testTimer;
        testTimer.Start();
        result.OnTestStart(curTest->m_testName);

        curTest->Run(result);

        int const testTimeInMs = testTimer.GetTimeInMs();
        if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs)
        {
            MemoryOutStream stream;
            stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
                      "ms but took " << testTimeInMs << "ms.";
            result.OnTestFailure(curTest->m_filename, curTest->m_lineNumber,
                                 curTest->m_testName, stream.GetText());
        }
        result.OnTestFinish(curTest->m_testName, testTimeInMs/1000.0f);

        curTest = curTest->next;
    }

    float const secondsElapsed = overallTimer.GetTimeInMs() / 1000.0f;
    reporter.ReportSummary(result.GetTestCount(), result.GetFailureCount(), secondsElapsed);

    return result.GetFailureCount();
}
コード例 #9
0
ファイル: TestList.cpp プロジェクト: tapvanvn/odatacpp-client
ListAdder::ListAdder(TestList& list, Test* test, ...)
{
    char * arg;
    va_list argList;
    va_start(argList, test);
    for(arg = va_arg(argList, char*); arg != nullptr; arg = va_arg(argList, char*))
    {
        char * key = arg;
        arg = va_arg(argList, char*);
        if(arg != nullptr)
        {
            char *value = arg;
            test->m_properties.Add(key, value);
        }
    }
    va_end(argList);

    // If on windows we could be either desktop or winrt. Make a requires property for the correct version.
    // Only a desktop runner environment can execute a desktop test case and vice versa on winrt.
    // This starts with visual studio versions after VS 2012.
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
#ifdef __cplusplus_winrt
    test->m_properties.Add("Requires", "winrt");
#else
    test->m_properties.Add("Requires", "desktop");
#endif
#endif

    list.Add(test);
}
コード例 #10
0
ファイル: UnitTest.cpp プロジェクト: DaiLiRong/rippled
UnitTests::TestList UnitTests::selectTests (
    String const& match, TestList const& tests) const noexcept
{
    TestList list;
    list.ensureStorageAllocated (tests.size ());

    int const indexOfDot = match.indexOfChar ('.');
    String const package = (indexOfDot == -1) ? match : match.substring (0, indexOfDot);
    String const testname = (indexOfDot == -1) ? ""
        : match.substring (indexOfDot + 1, match.length () + 1);

    if (package != String::empty)
    {
        if (testname != String::empty)
        {
            // "package.testname" : First test which matches
            for (int i = 0; i < tests.size(); ++i)
            {
                UnitTest* const test = tests [i];
                if (package.equalsIgnoreCase (test->getPackageName ()) &&
                    testname.equalsIgnoreCase (test->getClassName ()))
                {
                    list.add (test);
                    break;
                }
            }
        }
        else
        {
            // Get all tests in the package
            list = selectPackage (package, tests);

            // If no trailing slash on package, try tests
            if (list.size () == 0 && indexOfDot == -1)
            {
                // Try "package" as a testname
                list = selectTest (package, tests);
            }
        }
    }
    else if (testname != String::empty)
    {
        list = selectTest (testname, tests);
    }
    else
    {
        // All non manual tests
        for (int i = 0; i < tests.size(); ++i)
        {
            UnitTest* const test = tests [i];
            if (test->getWhen () != UnitTest::runManual)
                list.add (test);
        }
    }

    return list;
}
コード例 #11
0
ファイル: test.cpp プロジェクト: sourcey/libsourcey
void TestRunner::run()
{
    cout << "===============================================================" << endl;
    // cout << "running all tests" << endl;

    uint64_t start = time::hrtime();
    double duration = 0;
    TestList tests = this->tests();
    for (auto it = tests.begin(); it != tests.end(); ++it) {
        {
            std::lock_guard<std::mutex> guard(_mutex);
            _current = *it;
        }
        cout
            << "---------------------------------------------------------------" << endl;
        cout << _current->name << " starting" << endl;
        uint64_t test_start = time::hrtime();
        try {
            _current->run();
        } catch (std::exception& exc) {
            _current->errors.push_back(exc.what());
            cout << "exception thrown: " << exc.what() << endl;
        }
        _current->duration = (time::hrtime() - test_start) / 1e9;
        cout << _current->name << " ended after " << _current->duration << " seconds" << endl;
    }

    duration = (time::hrtime() - start) / 1e9;

    cout << "---------------------------------------------------------------" << endl;
    cout << "all tests completed after " << duration << " seconds" << endl;
    // cout << "summary: " << endl;

    for (auto it = tests.begin(); it != tests.end(); ++it) {
        if ((*it)->passed()) {
            cout << (*it)->name << " passed" << endl;
        } else {
            cout << (*it)->name << " failed" << endl;
        }
    }
}
コード例 #12
0
void UnitTests::runTests (TestList const& tests)
{
    m_results = new Results;
    for (int i = 0; i < tests.size (); ++i)
    {
        if (shouldAbortTests())
            break;
        runTest (*tests [i]);
    }
    m_results->secondsElapsed = RelativeTime (
        Time::getCurrentTime () - m_results->whenStarted).inSeconds ();
}
コード例 #13
0
ファイル: UnitTest.cpp プロジェクト: DaiLiRong/rippled
void UnitTests::runTests (TestList const& tests, int64 randomSeed)
{
    if (randomSeed == 0)
        randomSeed = Random().nextInt (0x7fffffff);
    m_random = Random (randomSeed);

    m_results = new Results;
    for (int i = 0; i < tests.size (); ++i)
    {
        if (shouldAbortTests())
            break;
        runTest (*tests [i]);
    }
    m_results->secondsElapsed = RelativeTime (
        Time::getCurrentTime () - m_results->whenStarted).inSeconds ();
}
コード例 #14
0
ファイル: TestRunner.cpp プロジェクト: fatman2021/sharm
int RunAllTests(TestReporter& reporter, TestList const& list, char const* suiteName, int const maxTestTimeInMs )
{
    TestResults result(&reporter);

    Timer overallTimer;
    overallTimer.Start();

    Test const* curTest = list.GetHead();
    while (curTest != 0)
    {
        if (suiteName == 0 || !std::strcmp(curTest->m_details.suiteName, suiteName))
        {
            Timer testTimer;
            testTimer.Start();
            result.OnTestStart(curTest->m_details);

            curTest->Run(result);

            int const testTimeInMs = testTimer.GetTimeInMs();
            if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_timeConstraintExempt)
            {
                MemoryOutStream stream;
                stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
                       "ms but took " << testTimeInMs << "ms.";
                result.OnTestFailure(curTest->m_details, stream.GetText());
            }
            result.OnTestFinish(curTest->m_details, (float)testTimeInMs);
        }

        curTest = curTest->next;
    }

    float const secondsElapsed = overallTimer.GetTimeInMs() / 1000.0f;
    reporter.ReportSummary(result.GetTotalTestCount(), result.GetFailedTestCount(), result.GetFailureCount(), secondsElapsed);

    return result.GetFailureCount();
}
コード例 #15
0
ファイル: ListTests.cpp プロジェクト: Wessi/OpenNI
TEST(ListTests, TestAll) 
{
	static TestStruct sValues[] = 
	{
		{ 1, 1.1 },
		{ 2, 2.2 },
		{ 3, 3.3 },
		{ 4, 4.4 },
	};

	// test empty
	TestList list;
	TestCurrentListState(list, 0, NULL);

	// test Clear() when empty
	ASSERT_EQ(list.Clear(), XN_STATUS_OK);
	TestCurrentListState(list, 0, NULL);

	// make sure AddBefore and AddAfter fail when receiving End()
	ASSERT_EQ(list.AddBefore(list.End(), sValues[0]), XN_STATUS_ILLEGAL_POSITION);
	ASSERT_EQ(list.AddAfter(list.End(), sValues[0]), XN_STATUS_ILLEGAL_POSITION);

	// test AddLast when empty
	ASSERT_EQ(list.AddLast(sValues[0]), XN_STATUS_OK);
	TestCurrentListState(list, 1, sValues);

	// test Clear when only one
	ASSERT_EQ(list.Clear(), XN_STATUS_OK);
	TestCurrentListState(list, 0, NULL);

	// test AddFirst when empty
	ASSERT_EQ(list.AddFirst(sValues[2]), XN_STATUS_OK);
	TestCurrentListState(list, 1, sValues + 2);

	// test AddFirst when having one
	ASSERT_EQ(list.AddFirst(sValues[1]), XN_STATUS_OK);
	TestCurrentListState(list, 2, sValues + 1);

	// test AddBefore in the beginning
	ASSERT_EQ(list.AddBefore(list.Begin(), sValues[0]), XN_STATUS_OK);
	TestCurrentListState(list, 3, sValues);

	// test Remove by value
	ASSERT_EQ(list.Remove(sValues[1]), XN_STATUS_OK);
	TestStruct aTemp[] = 
	{
		sValues[0],
		sValues[2]
	};
	TestCurrentListState(list, 2, aTemp);

	// and Remove by iterator
	ASSERT_EQ(list.Remove(++list.Begin()), XN_STATUS_OK);
	TestCurrentListState(list, 1, sValues);

	// test AddLast when having one
	ASSERT_EQ(list.AddLast(sValues[1]), XN_STATUS_OK);
	TestCurrentListState(list, 2, sValues);

	// test AddAfter in the end
	ASSERT_EQ(list.AddAfter(list.ReverseBegin(), sValues[2]), XN_STATUS_OK);
	TestCurrentListState(list, 3, sValues);

	// test AddBefore in the middle
	ASSERT_EQ(list.AddBefore(++list.Begin(), sValues[3]), XN_STATUS_OK);
	TestStruct aTemp2[] = 
	{
		sValues[0],
		sValues[3],
		sValues[1],
		sValues[2]
	};
	TestCurrentListState(list, 4, aTemp2);

	// remove one (needed for next test)
	ASSERT_EQ(list.Remove(++list.Begin()), XN_STATUS_OK);
	TestStruct aTemp3[] = 
	{
		sValues[0],
		sValues[1],
		sValues[2]
	};
	TestCurrentListState(list, 3, aTemp3);

	// test AddAfter in the middle
	ASSERT_EQ(list.AddAfter(--list.ReverseBegin(), sValues[3]), XN_STATUS_OK);
	TestStruct aTemp4[] = 
	{
		sValues[0],
		sValues[1],
		sValues[3],
		sValues[2]
	};
	TestCurrentListState(list, 4, aTemp4);

	// test const Find()
	const TestList& constList = list;
	TestList::ConstIterator constIt = constList.Find(sValues[3]);
	ASSERT_NE(constIt, constList.End());
	ASSERT_EQ(constIt, --constList.ReverseBegin());

	// and non-const Find()
	TestList::Iterator it = list.Find(sValues[2]);
	ASSERT_NE(it, list.End());
	ASSERT_EQ(it, list.ReverseBegin());

	// try to find something that's not in the list
	TestStruct notInList = { 17, 7.4 };
	ASSERT_EQ(constList.Find(notInList), constList.End());
	ASSERT_EQ(list.Find(notInList), list.End());

	// try to remove something that's not in the list
	ASSERT_EQ(list.Remove(notInList), XN_STATUS_NO_MATCH);

	// try to remove end
	ASSERT_EQ(list.Remove(list.End()), XN_STATUS_ILLEGAL_POSITION);
}
コード例 #16
0
int main(int,char**)
{
    TestList<TestUpdaterOptions> tests;
    tests.addTest(&TestUpdaterOptions::testOldFormatArgs);
    return TestUtils::runTest(tests);
}
コード例 #17
0
ファイル: TestList.cpp プロジェクト: Aksej/ia
ListAdder::ListAdder(TestList& list, Test* test) {
  list.Add(test);
}
コード例 #18
0
void main()
{
    TestList testlist;
	testlist.RunAllTests();
}
コード例 #19
0
ファイル: test_list.cpp プロジェクト: andysworkshop/avr-stl
void loop() {
    delay(1000);
    l.RunTest();
}