EmbeddedUnit
TestCase.c
Go to the documentation of this file.
1 
34 #include "Test.h"
35 #include "TestCase.h"
36 #include "TestResult.h"
37 
38 static TestResult* result_;
39 static TestCase* self_;
40 
41 char* TestCase_name(TestCase* self)
42 {
43  return self->name;
44 }
45 
46 void TestCase_run(TestCase* self,TestResult* result)
47 {
48  TestResult_startTest(result, (Test*)self);
49  if (self->setUp) {
50  self->setUp();
51  }
52  if (self->runTest) {
53  TestResult* wr =result_; /*push*/
54  TestCase* ws = self_; /*push*/
55  result_ = result;
56  self_ = self;
57  self->runTest();
58  result_ = wr; /*pop*/
59  self_ = ws; /*pop*/
60  }
61  if (self->tearDown) {
62  self->tearDown();
63  }
64  TestResult_endTest(result, (Test*)self);
65 }
66 
67 int TestCase_countTestCases(TestCase* self)
68 {
69  return 1;
70 }
71 
72 const TestImplement TestCaseImplement = {
73  (TestNameFunction) TestCase_name,
74  (TestRunFunction) TestCase_run,
75  (TestCountTestCasesFunction)TestCase_countTestCases,
76 };
77 
78 void addFailure(const char *msg, long line, const char *file)
79 {
80  TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file);
81 }
Definition: Test.h:56