コード例 #1
0
bool TestFind(tTree &Tree, int Key, int Value)
{
    DbgOutput("TestTreeFind(" << Key << ", " << Value << ")");
    int *pFound = Tree.Find(Key);
    bool Pass = ((!pFound && (Value == -1)) || (pFound && (*pFound == Value)));
    IfFail("****Failed: TestTreeFind(" << Key << "); Tree.Find() returned " << pFound << ", *return is " << (pFound ? *pFound : INT_MAX));
    return Pass;
}                                   // TestFind()
コード例 #2
0
ファイル: debug.cpp プロジェクト: ellysh/notecase
void Trace(const char *fmt, ...)
{
	char buffer[1024] = "";

	// create string using format and list of parameters
	va_list args;
	va_start(args, fmt);
	vsnprintf(buffer, sizeof(buffer)-1, fmt, args);
	va_end(args);

	DbgOutput(buffer);
}
コード例 #3
0
static int Test(tTree &Tree, int *pSeq, tTraversalOrder Order, int &Tried)
    {
    DbgOutput("Iterator begin(), end(), and equality for " << OrderStrings[Order]);

    int  ActualValue   = 0;
    int  Count         = 0;
    int  ExpectedValue = 0;
    bool Pass          = false;
    int  Run           = 0;

    tIter Begin  = Tree.begin(Order);
    tIter End    = Tree.end(  Order);
    tIter Uninit;

    ++Run;
    ActualValue   = Begin->first;
    ExpectedValue = pSeq[0];
    Pass          = (ActualValue == ExpectedValue);
    Count        += (int) Pass;
    IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", Begin->first is " << ActualValue << ", expected " << ExpectedValue);

    // cout << "    Begin  is "; Begin .Dump(); cout << endl << flush;
    // cout << "    End    is "; End   .Dump(); cout << endl << flush;
    // cout << "    Uninit is "; Uninit.Dump(); cout << endl << flush;

    ++Run; Pass = (Begin == Begin            ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", Begin != Begin"       );
    ++Run; Pass = (Begin == Tree.begin(Order)); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", Begin != Tree.begin()");
    ++Run; Pass = (Begin != Uninit           ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", Begin == Uninit"      );
    ++Run; Pass = (End   == End              ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", End != End"           );
    ++Run; Pass = (End   == Tree.end(Order)  ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", End != Tree.end()"    );
    ++Run; Pass = (End   != Uninit           ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", End == Uninit"        );
    ++Run; Pass = (Begin != End              ); Count += Pass; IfFail("****Failed: TestBeginAndEnd(" << OrderStrings[Order] << "); Count " << Count << ", Begin == End"         );

    Tried += Run;
    DbgOutput("    " << Run << " tests run, " << Count << " passed.");
    return Count;
    }                                   // Test()
コード例 #4
0
ファイル: debug.cpp プロジェクト: ellysh/notecase
void Assert(int exp, const char *fmt, ...)
{
	if(!exp)
	{
		char buffer[1024] = "";

		// create string using format and list of parameters
		va_list args;
		va_start(args, fmt);
		vsnprintf(buffer, sizeof(buffer)-1, fmt, args);
		va_end(args);

		DbgOutput(buffer);

	#ifdef _WIN32
		assert(false);	//trigger debugger event
	#else
		exit(1);
	#endif
    }
}
コード例 #5
0
static int Test(tTree &Tree, int *pSeq, tTraversalOrder Order, int &Tried)
    {
    DbgOutput("Iterator dereference for " << OrderStrings[Order]);

    int   ActualKey   = 0;
    int   Count       = 0;
    int   ExpectedKey = 0;
    tIter Iter;
    bool  Pass        = false;
    int   Run         = 0;

    ++Run;
    Iter        = Tree.begin(Order);
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[0];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Tree.begin() Actual " << ActualKey << ", Expected " << ExpectedKey);

    ++Run;
    ++Iter;
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[1];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Count " << Count << ", ++Iter Actual " << ActualKey << ", Expected " << ExpectedKey);

    ++Run;
    ++Iter;
    ++Iter;
    ++Iter;
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[4];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Count " << Count << ", ++(++(++Iter)) Actual " << ActualKey << ", Expected " << ExpectedKey);

    ++Run;
    Iter++;
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[5];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Count " << Count << ", Iter++ Actual " << ActualKey << ", Expected " << ExpectedKey);

    ++Run;
    --Iter;
    --Iter;
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[3];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Count " << Count << ", --(--Iter) Actual " << ActualKey << ", Expected " << ExpectedKey);

    ++Run;
    Iter--;
    ActualKey   = Iter->first;
    ExpectedKey = pSeq[2];
    Pass        = (ActualKey == ExpectedKey);
    Count      += (int) Pass;
    IfFail("****Failed: TestIterIncAndDec(" << OrderStrings[Order] << "); Count " << Count << ", Iter-- Actual " << ActualKey << ", Expected " << ExpectedKey);

    Tried += Run;
    DbgOutput("    " << Run << " tests run, " << Count << " passed.");
    return Count;
    }                                   // Test()