File: BaseTest.cpp

package info (click to toggle)
libjboss-profiler-java 1.0.CR4-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 376 kB
  • ctags: 488
  • sloc: cpp: 2,713; java: 1,394; xml: 169; sh: 158; makefile: 95
file content (53 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (2)
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
#include "BaseTest.h"
#include <time.h>
BaseTest::BaseTest()
{
	currentTestName=NULL;
	currentStatus=0;
	startTime=0;
}

BaseTest::~BaseTest()
{
}


	/** A test method needs to inform that his test is beggining. This is because we not using any reflection here */
void BaseTest::startTest(char * testName)
{
	currentTestName = testName;
	currentStatus=0;
	startTime = time(&startTime);
	printf ("Test \"%s\" is starting\n",currentTestName);
}

	/** A test method needs to inform that his test finished  */
void BaseTest::stopTest()
{
	time_t finishTime;
	finishTime = time(&finishTime);
	time_t difference = finishTime - startTime;
	if (currentStatus)
	{
		printf ("Test \"%s\" failed with status %d, executed in %ld seconds\n",currentTestName,currentStatus, difference);
	} else
	{
		printf ("Test \"%s\" finished without any errors, executed in %ld seconds\n",currentTestName, difference);
	}
	
}

short BaseTest::assert(short clause, char * message)
{
	if (clause)
	{
		printf ("Test %s failure = %s\n",currentTestName,message);
	}
	currentStatus=clause;
	return currentStatus;
}

void BaseTest::fail(char * failMessage)
{
	printf ("%s failed because of %s\n",currentTestName,failMessage);
}