Unit Testing framework based on http://cpputest.github.io/

CppUTest

Where to find more information

Getting test reports on the console

You may need to tailor the file src/Platforms/mbed/UtestPlatform.cpp to your needs. In particular, if you want console output, you might want to look at the function PlatformSpecificPutchar().

Quick introduction (some code!)

To write your first test, all you need is a new cpp file with a TEST_GROUP and a TEST, like:

#include "CppUTest/TestHarness.h"

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirstTest)
{
   FAIL("Fail me!");
}

This test will fail.

You can add new tests to the test group by just writing more tests in the file, like this:

TEST(FirstTestGroup, SecondTest)
{
   STRCMP_EQUAL("hello", "world");
   LONGS_EQUAL(1, 2);
   CHECK(false);
}

You do need to trigger the tests from somewhere in your program. It could look something like:

#include "CppUTest/TestRegistry.h"
#include "CppUTest/CommandLineTestRunner.h"

int main(int ac, char** av)
{
    ....
    unsigned failureCount = 0;
    {
        ConsoleTestOutput output;
        CommandLineTestRunner runner(ac, av, &output, TestRegistry::getCurrentRegistry());
        failureCount = runner.runAllTestsMain();
    }

    if (failureCount == 0) {
        console.printf("PASSED\r\n");
    }
    ...
}

For more information, We’d recommend to read the manual or, even better, check some existing tests such as SimpleStringTest or (a bit more complicated) MemoryLeakDetectorTest or the mocking tests or just check out the Cheat Sheet.

Committer:
Rohit Grover
Date:
Tue Jun 17 15:52:54 2014 +0100
Revision:
1:4769360130ed
Parent:
0:0b799af9d58e
updating to the latest version of cppUtest; tested against nordic's m-kit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 0:0b799af9d58e 1 /*
rgrover1 0:0b799af9d58e 2 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
rgrover1 0:0b799af9d58e 3 * All rights reserved.
rgrover1 0:0b799af9d58e 4 *
rgrover1 0:0b799af9d58e 5 * Redistribution and use in source and binary forms, with or without
rgrover1 0:0b799af9d58e 6 * modification, are permitted provided that the following conditions are met:
rgrover1 0:0b799af9d58e 7 * * Redistributions of source code must retain the above copyright
rgrover1 0:0b799af9d58e 8 * notice, this list of conditions and the following disclaimer.
rgrover1 0:0b799af9d58e 9 * * Redistributions in binary form must reproduce the above copyright
rgrover1 0:0b799af9d58e 10 * notice, this list of conditions and the following disclaimer in the
rgrover1 0:0b799af9d58e 11 * documentation and/or other materials provided with the distribution.
rgrover1 0:0b799af9d58e 12 * * Neither the name of the <organization> nor the
rgrover1 0:0b799af9d58e 13 * names of its contributors may be used to endorse or promote products
rgrover1 0:0b799af9d58e 14 * derived from this software without specific prior written permission.
rgrover1 0:0b799af9d58e 15 *
rgrover1 0:0b799af9d58e 16 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
rgrover1 0:0b799af9d58e 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rgrover1 0:0b799af9d58e 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rgrover1 0:0b799af9d58e 19 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
rgrover1 0:0b799af9d58e 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rgrover1 0:0b799af9d58e 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rgrover1 0:0b799af9d58e 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
rgrover1 0:0b799af9d58e 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rgrover1 0:0b799af9d58e 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
rgrover1 0:0b799af9d58e 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rgrover1 0:0b799af9d58e 26 */
rgrover1 0:0b799af9d58e 27
rgrover1 0:0b799af9d58e 28 #include "CppUTest/TestHarness.h"
rgrover1 0:0b799af9d58e 29 #include "CppUTest/TestRegistry.h"
rgrover1 0:0b799af9d58e 30 #include "CppUTest/PlatformSpecificFunctions.h"
rgrover1 0:0b799af9d58e 31 #include "CppUTest/TestOutput.h"
rgrover1 0:0b799af9d58e 32
rgrover1 0:0b799af9d58e 33 bool doubles_equal(double d1, double d2, double threshold)
rgrover1 0:0b799af9d58e 34 {
rgrover1 0:0b799af9d58e 35 if (PlatformSpecificIsNan(d1) || PlatformSpecificIsNan(d2) || PlatformSpecificIsNan(threshold))
rgrover1 0:0b799af9d58e 36 return false;
rgrover1 0:0b799af9d58e 37 return PlatformSpecificFabs(d1 - d2) <= threshold;
rgrover1 0:0b799af9d58e 38 }
rgrover1 0:0b799af9d58e 39
rgrover1 0:0b799af9d58e 40 /* Sometimes stubs use the CppUTest assertions.
rgrover1 0:0b799af9d58e 41 * Its not correct to do so, but this small helper class will prevent a segmentation fault and instead
rgrover1 0:0b799af9d58e 42 * will give an error message and also the file/line of the check that was executed outside the tests.
rgrover1 0:0b799af9d58e 43 */
rgrover1 0:0b799af9d58e 44 class OutsideTestRunnerUTest: public UtestShell
rgrover1 0:0b799af9d58e 45 {
rgrover1 0:0b799af9d58e 46 public:
rgrover1 0:0b799af9d58e 47 static OutsideTestRunnerUTest& instance();
rgrover1 0:0b799af9d58e 48 virtual TestResult& getTestResult()
rgrover1 0:0b799af9d58e 49 {
rgrover1 0:0b799af9d58e 50 return defaultTestResult;
rgrover1 0:0b799af9d58e 51 }
rgrover1 0:0b799af9d58e 52 virtual void exitCurrentTest()
rgrover1 0:0b799af9d58e 53 {
rgrover1 0:0b799af9d58e 54 }
rgrover1 0:0b799af9d58e 55 virtual ~OutsideTestRunnerUTest()
rgrover1 0:0b799af9d58e 56 {
rgrover1 0:0b799af9d58e 57 }
rgrover1 0:0b799af9d58e 58 private:
rgrover1 0:0b799af9d58e 59 OutsideTestRunnerUTest() :
rgrover1 0:0b799af9d58e 60 UtestShell("\n\t NOTE: Assertion happened without being in a test run (perhaps in main?)", "\n\t Something is very wrong. Check this assertion and fix", "unknown file", 0),
rgrover1 0:0b799af9d58e 61 defaultTestResult(defaultOutput)
rgrover1 0:0b799af9d58e 62 {
rgrover1 0:0b799af9d58e 63 }
rgrover1 0:0b799af9d58e 64 ConsoleTestOutput defaultOutput;
rgrover1 0:0b799af9d58e 65 TestResult defaultTestResult;
rgrover1 0:0b799af9d58e 66 };
rgrover1 0:0b799af9d58e 67
rgrover1 0:0b799af9d58e 68 OutsideTestRunnerUTest& OutsideTestRunnerUTest::instance()
rgrover1 0:0b799af9d58e 69 {
rgrover1 0:0b799af9d58e 70 static OutsideTestRunnerUTest instance_;
rgrover1 0:0b799af9d58e 71 return instance_;
rgrover1 0:0b799af9d58e 72 }
rgrover1 0:0b799af9d58e 73
rgrover1 0:0b799af9d58e 74 /*
rgrover1 0:0b799af9d58e 75 * Below helpers are used for the PlatformSpecificSetJmp and LongJmp. They pass a method for what needs to happen after
rgrover1 0:0b799af9d58e 76 * the jump, so that the stack stays right.
rgrover1 0:0b799af9d58e 77 *
rgrover1 0:0b799af9d58e 78 */
rgrover1 0:0b799af9d58e 79
rgrover1 0:0b799af9d58e 80 extern "C" {
rgrover1 0:0b799af9d58e 81
rgrover1 0:0b799af9d58e 82 static void helperDoTestSetup(void* data)
rgrover1 0:0b799af9d58e 83 {
rgrover1 0:0b799af9d58e 84 ((Utest*)data)->setup();
rgrover1 0:0b799af9d58e 85 }
rgrover1 0:0b799af9d58e 86
rgrover1 0:0b799af9d58e 87 static void helperDoTestBody(void* data)
rgrover1 0:0b799af9d58e 88 {
rgrover1 0:0b799af9d58e 89 ((Utest*)data)->testBody();
rgrover1 0:0b799af9d58e 90 }
rgrover1 0:0b799af9d58e 91
rgrover1 0:0b799af9d58e 92 static void helperDoTestTeardown(void* data)
rgrover1 0:0b799af9d58e 93 {
rgrover1 0:0b799af9d58e 94 ((Utest*)data)->teardown();
rgrover1 0:0b799af9d58e 95 }
rgrover1 0:0b799af9d58e 96
rgrover1 0:0b799af9d58e 97 struct HelperTestRunInfo
rgrover1 0:0b799af9d58e 98 {
rgrover1 0:0b799af9d58e 99 HelperTestRunInfo(UtestShell* shell, TestPlugin* plugin, TestResult* result) : shell_(shell), plugin_(plugin), result_(result){}
rgrover1 0:0b799af9d58e 100
rgrover1 0:0b799af9d58e 101 UtestShell* shell_;
rgrover1 0:0b799af9d58e 102 TestPlugin* plugin_;
rgrover1 0:0b799af9d58e 103 TestResult* result_;
rgrover1 0:0b799af9d58e 104 };
rgrover1 0:0b799af9d58e 105
rgrover1 0:0b799af9d58e 106 static void helperDoRunOneTestInCurrentProcess(void* data)
rgrover1 0:0b799af9d58e 107 {
rgrover1 0:0b799af9d58e 108 HelperTestRunInfo* runInfo = (HelperTestRunInfo*) data;
rgrover1 0:0b799af9d58e 109
rgrover1 0:0b799af9d58e 110 UtestShell* shell = runInfo->shell_;
rgrover1 0:0b799af9d58e 111 TestPlugin* plugin = runInfo->plugin_;
rgrover1 0:0b799af9d58e 112 TestResult* result = runInfo->result_;
rgrover1 0:0b799af9d58e 113
rgrover1 0:0b799af9d58e 114 shell->runOneTestInCurrentProcess(plugin, *result);
rgrover1 0:0b799af9d58e 115 }
rgrover1 0:0b799af9d58e 116
rgrover1 0:0b799af9d58e 117 static void helperDoRunOneTestSeperateProcess(void* data)
rgrover1 0:0b799af9d58e 118 {
rgrover1 0:0b799af9d58e 119 HelperTestRunInfo* runInfo = (HelperTestRunInfo*) data;
rgrover1 0:0b799af9d58e 120
rgrover1 0:0b799af9d58e 121 UtestShell* shell = runInfo->shell_;
rgrover1 0:0b799af9d58e 122 TestPlugin* plugin = runInfo->plugin_;
rgrover1 0:0b799af9d58e 123 TestResult* result = runInfo->result_;
rgrover1 0:0b799af9d58e 124 PlatformSpecificRunTestInASeperateProcess(shell, plugin, result);
rgrover1 0:0b799af9d58e 125 }
rgrover1 0:0b799af9d58e 126
rgrover1 0:0b799af9d58e 127 }
rgrover1 0:0b799af9d58e 128
rgrover1 0:0b799af9d58e 129 /******************************** */
rgrover1 0:0b799af9d58e 130
rgrover1 0:0b799af9d58e 131 UtestShell::UtestShell() :
rgrover1 0:0b799af9d58e 132 group_("UndefinedTestGroup"), name_("UndefinedTest"), file_("UndefinedFile"), lineNumber_(0), next_(&NullTestShell::instance()), isRunAsSeperateProcess_(false), hasFailed_(false)
rgrover1 0:0b799af9d58e 133 {
rgrover1 0:0b799af9d58e 134 }
rgrover1 0:0b799af9d58e 135
rgrover1 0:0b799af9d58e 136 UtestShell::UtestShell(const char* groupName, const char* testName, const char* fileName, int lineNumber) :
rgrover1 0:0b799af9d58e 137 group_(groupName), name_(testName), file_(fileName), lineNumber_(lineNumber), next_(&NullTestShell::instance()), isRunAsSeperateProcess_(false), hasFailed_(false)
rgrover1 0:0b799af9d58e 138 {
rgrover1 0:0b799af9d58e 139 }
rgrover1 0:0b799af9d58e 140
rgrover1 0:0b799af9d58e 141 UtestShell::UtestShell(const char* groupName, const char* testName, const char* fileName, int lineNumber, UtestShell* nextTest) :
rgrover1 0:0b799af9d58e 142 group_(groupName), name_(testName), file_(fileName), lineNumber_(lineNumber), next_(nextTest), isRunAsSeperateProcess_(false), hasFailed_(false)
rgrover1 0:0b799af9d58e 143 {
rgrover1 0:0b799af9d58e 144 }
rgrover1 0:0b799af9d58e 145
rgrover1 0:0b799af9d58e 146 UtestShell::~UtestShell()
rgrover1 0:0b799af9d58e 147 {
rgrover1 0:0b799af9d58e 148 }
rgrover1 0:0b799af9d58e 149
rgrover1 0:0b799af9d58e 150 static void defaultCrashMethod()
rgrover1 0:0b799af9d58e 151 {
rgrover1 0:0b799af9d58e 152 UtestShell* ptr = (UtestShell*) 0x0; ptr->countTests();
rgrover1 0:0b799af9d58e 153 }
rgrover1 0:0b799af9d58e 154
rgrover1 0:0b799af9d58e 155 static void (*pleaseCrashMeRightNow) () = defaultCrashMethod;
rgrover1 0:0b799af9d58e 156
rgrover1 0:0b799af9d58e 157 void UtestShell::setCrashMethod(void (*crashme)())
rgrover1 0:0b799af9d58e 158 {
rgrover1 0:0b799af9d58e 159 pleaseCrashMeRightNow = crashme;
rgrover1 0:0b799af9d58e 160 }
rgrover1 0:0b799af9d58e 161
rgrover1 0:0b799af9d58e 162 void UtestShell::resetCrashMethod()
rgrover1 0:0b799af9d58e 163 {
rgrover1 0:0b799af9d58e 164 pleaseCrashMeRightNow = defaultCrashMethod;
rgrover1 0:0b799af9d58e 165 }
rgrover1 0:0b799af9d58e 166
rgrover1 0:0b799af9d58e 167 void UtestShell::crash()
rgrover1 0:0b799af9d58e 168 {
rgrover1 0:0b799af9d58e 169 pleaseCrashMeRightNow();
rgrover1 0:0b799af9d58e 170 }
rgrover1 0:0b799af9d58e 171
rgrover1 0:0b799af9d58e 172 void UtestShell::runOneTest(TestPlugin* plugin, TestResult& result)
rgrover1 0:0b799af9d58e 173 {
rgrover1 0:0b799af9d58e 174 HelperTestRunInfo runInfo(this, plugin, &result);
rgrover1 0:0b799af9d58e 175 if (isRunInSeperateProcess())
rgrover1 0:0b799af9d58e 176 PlatformSpecificSetJmp(helperDoRunOneTestSeperateProcess, &runInfo);
rgrover1 0:0b799af9d58e 177 else
rgrover1 0:0b799af9d58e 178 PlatformSpecificSetJmp(helperDoRunOneTestInCurrentProcess, &runInfo);
rgrover1 0:0b799af9d58e 179 }
rgrover1 0:0b799af9d58e 180
rgrover1 0:0b799af9d58e 181 Utest* UtestShell::createTest()
rgrover1 0:0b799af9d58e 182 {
rgrover1 0:0b799af9d58e 183 return new Utest();
rgrover1 0:0b799af9d58e 184 }
rgrover1 0:0b799af9d58e 185
rgrover1 0:0b799af9d58e 186 void UtestShell::destroyTest(Utest* test)
rgrover1 0:0b799af9d58e 187 {
rgrover1 0:0b799af9d58e 188 delete test;
rgrover1 0:0b799af9d58e 189 }
rgrover1 0:0b799af9d58e 190
rgrover1 0:0b799af9d58e 191 void UtestShell::runOneTestInCurrentProcess(TestPlugin* plugin, TestResult& result)
rgrover1 0:0b799af9d58e 192 {
rgrover1 0:0b799af9d58e 193 plugin->runAllPreTestAction(*this, result);
rgrover1 0:0b799af9d58e 194
rgrover1 0:0b799af9d58e 195 //save test context, so that test class can be tested
rgrover1 0:0b799af9d58e 196 UtestShell* savedTest = UtestShell::getCurrent();
rgrover1 0:0b799af9d58e 197 TestResult* savedResult = UtestShell::getTestResult();
rgrover1 0:0b799af9d58e 198
rgrover1 0:0b799af9d58e 199 result.countRun();
rgrover1 0:0b799af9d58e 200 UtestShell::setTestResult(&result);
rgrover1 0:0b799af9d58e 201 UtestShell::setCurrentTest(this);
rgrover1 0:0b799af9d58e 202
rgrover1 0:0b799af9d58e 203 Utest* testToRun = createTest();
rgrover1 0:0b799af9d58e 204 testToRun->run();
rgrover1 0:0b799af9d58e 205 destroyTest(testToRun);
rgrover1 0:0b799af9d58e 206
rgrover1 0:0b799af9d58e 207 UtestShell::setCurrentTest(savedTest);
rgrover1 0:0b799af9d58e 208 UtestShell::setTestResult(savedResult);
rgrover1 0:0b799af9d58e 209
rgrover1 0:0b799af9d58e 210 plugin->runAllPostTestAction(*this, result);
rgrover1 0:0b799af9d58e 211 }
rgrover1 0:0b799af9d58e 212
rgrover1 0:0b799af9d58e 213 UtestShell *UtestShell::getNext() const
rgrover1 0:0b799af9d58e 214 {
rgrover1 0:0b799af9d58e 215 return next_;
rgrover1 0:0b799af9d58e 216 }
rgrover1 0:0b799af9d58e 217
rgrover1 0:0b799af9d58e 218 UtestShell* UtestShell::addTest(UtestShell *test)
rgrover1 0:0b799af9d58e 219 {
rgrover1 0:0b799af9d58e 220 next_ = test;
rgrover1 0:0b799af9d58e 221 return this;
rgrover1 0:0b799af9d58e 222 }
rgrover1 0:0b799af9d58e 223
rgrover1 0:0b799af9d58e 224 int UtestShell::countTests()
rgrover1 0:0b799af9d58e 225 {
rgrover1 0:0b799af9d58e 226 return next_->countTests() + 1;
rgrover1 0:0b799af9d58e 227 }
rgrover1 0:0b799af9d58e 228
rgrover1 0:0b799af9d58e 229 bool UtestShell::isNull() const
rgrover1 0:0b799af9d58e 230 {
rgrover1 0:0b799af9d58e 231 return false;
rgrover1 0:0b799af9d58e 232 }
rgrover1 0:0b799af9d58e 233
rgrover1 0:0b799af9d58e 234 SimpleString UtestShell::getMacroName() const
rgrover1 0:0b799af9d58e 235 {
rgrover1 0:0b799af9d58e 236 return "TEST";
rgrover1 0:0b799af9d58e 237 }
rgrover1 0:0b799af9d58e 238
rgrover1 0:0b799af9d58e 239 const SimpleString UtestShell::getName() const
rgrover1 0:0b799af9d58e 240 {
rgrover1 0:0b799af9d58e 241 return SimpleString(name_);
rgrover1 0:0b799af9d58e 242 }
rgrover1 0:0b799af9d58e 243
rgrover1 0:0b799af9d58e 244 const SimpleString UtestShell::getGroup() const
rgrover1 0:0b799af9d58e 245 {
rgrover1 0:0b799af9d58e 246 return SimpleString(group_);
rgrover1 0:0b799af9d58e 247 }
rgrover1 0:0b799af9d58e 248
rgrover1 0:0b799af9d58e 249 SimpleString UtestShell::getFormattedName() const
rgrover1 0:0b799af9d58e 250 {
rgrover1 0:0b799af9d58e 251 SimpleString formattedName(getMacroName());
rgrover1 0:0b799af9d58e 252 formattedName += "(";
rgrover1 0:0b799af9d58e 253 formattedName += group_;
rgrover1 0:0b799af9d58e 254 formattedName += ", ";
rgrover1 0:0b799af9d58e 255 formattedName += name_;
rgrover1 0:0b799af9d58e 256 formattedName += ")";
rgrover1 0:0b799af9d58e 257
rgrover1 0:0b799af9d58e 258 return formattedName;
rgrover1 0:0b799af9d58e 259 }
rgrover1 0:0b799af9d58e 260
rgrover1 0:0b799af9d58e 261 bool UtestShell::hasFailed() const
rgrover1 0:0b799af9d58e 262 {
rgrover1 0:0b799af9d58e 263 return hasFailed_;
rgrover1 0:0b799af9d58e 264 }
rgrover1 0:0b799af9d58e 265
rgrover1 0:0b799af9d58e 266 const char* UtestShell::getProgressIndicator() const
rgrover1 0:0b799af9d58e 267 {
rgrover1 0:0b799af9d58e 268 return ".";
rgrover1 0:0b799af9d58e 269 }
rgrover1 0:0b799af9d58e 270
rgrover1 0:0b799af9d58e 271 bool UtestShell::isRunInSeperateProcess() const
rgrover1 0:0b799af9d58e 272 {
rgrover1 0:0b799af9d58e 273 return isRunAsSeperateProcess_;
rgrover1 0:0b799af9d58e 274 }
rgrover1 0:0b799af9d58e 275
rgrover1 0:0b799af9d58e 276 void UtestShell::setRunInSeperateProcess()
rgrover1 0:0b799af9d58e 277 {
rgrover1 0:0b799af9d58e 278 isRunAsSeperateProcess_ = true;
rgrover1 0:0b799af9d58e 279 }
rgrover1 0:0b799af9d58e 280
rgrover1 0:0b799af9d58e 281
rgrover1 0:0b799af9d58e 282 void UtestShell::setFileName(const char* fileName)
rgrover1 0:0b799af9d58e 283 {
rgrover1 0:0b799af9d58e 284 file_ = fileName;
rgrover1 0:0b799af9d58e 285 }
rgrover1 0:0b799af9d58e 286
rgrover1 0:0b799af9d58e 287 void UtestShell::setLineNumber(int lineNumber)
rgrover1 0:0b799af9d58e 288 {
rgrover1 0:0b799af9d58e 289 lineNumber_ = lineNumber;
rgrover1 0:0b799af9d58e 290 }
rgrover1 0:0b799af9d58e 291
rgrover1 0:0b799af9d58e 292 void UtestShell::setGroupName(const char* groupName)
rgrover1 0:0b799af9d58e 293 {
rgrover1 0:0b799af9d58e 294 group_ = groupName;
rgrover1 0:0b799af9d58e 295 }
rgrover1 0:0b799af9d58e 296
rgrover1 0:0b799af9d58e 297 void UtestShell::setTestName(const char* testName)
rgrover1 0:0b799af9d58e 298 {
rgrover1 0:0b799af9d58e 299 name_ = testName;
rgrover1 0:0b799af9d58e 300 }
rgrover1 0:0b799af9d58e 301
rgrover1 0:0b799af9d58e 302 const SimpleString UtestShell::getFile() const
rgrover1 0:0b799af9d58e 303 {
rgrover1 0:0b799af9d58e 304 return SimpleString(file_);
rgrover1 0:0b799af9d58e 305 }
rgrover1 0:0b799af9d58e 306
rgrover1 0:0b799af9d58e 307 int UtestShell::getLineNumber() const
rgrover1 0:0b799af9d58e 308 {
rgrover1 0:0b799af9d58e 309 return lineNumber_;
rgrover1 0:0b799af9d58e 310 }
rgrover1 0:0b799af9d58e 311
rgrover1 0:0b799af9d58e 312 bool UtestShell::shouldRun(const TestFilter& groupFilter, const TestFilter& nameFilter) const
rgrover1 0:0b799af9d58e 313 {
rgrover1 0:0b799af9d58e 314 if (groupFilter.match(group_) && nameFilter.match(name_)) return true;
rgrover1 0:0b799af9d58e 315
rgrover1 0:0b799af9d58e 316 return false;
rgrover1 0:0b799af9d58e 317 }
rgrover1 0:0b799af9d58e 318
rgrover1 0:0b799af9d58e 319 void UtestShell::failWith(const TestFailure& failure)
rgrover1 0:0b799af9d58e 320 {
rgrover1 0:0b799af9d58e 321 failWith(failure, NormalTestTerminator());
rgrover1 0:0b799af9d58e 322 }
rgrover1 0:0b799af9d58e 323
rgrover1 0:0b799af9d58e 324 void UtestShell::failWith(const TestFailure& failure, const TestTerminator& terminator)
rgrover1 0:0b799af9d58e 325 {
rgrover1 0:0b799af9d58e 326 hasFailed_ = true;
rgrover1 0:0b799af9d58e 327 getTestResult()->addFailure(failure);
rgrover1 0:0b799af9d58e 328 terminator.exitCurrentTest();
rgrover1 0:0b799af9d58e 329 }
rgrover1 0:0b799af9d58e 330
rgrover1 0:0b799af9d58e 331 void UtestShell::assertTrue(bool condition, const char * checkString, const char* conditionString, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 332 {
rgrover1 0:0b799af9d58e 333 assertTrueText(condition, checkString, conditionString, "", fileName, lineNumber, testTerminator);
rgrover1 0:0b799af9d58e 334 }
rgrover1 0:0b799af9d58e 335
rgrover1 0:0b799af9d58e 336 void UtestShell::assertTrueText(bool condition, const char *checkString, const char *conditionString, const char* text, const char *fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 337 {
rgrover1 0:0b799af9d58e 338 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 339 if (!condition)
rgrover1 0:0b799af9d58e 340 failWith(CheckFailure(this, fileName, lineNumber, checkString, conditionString, text), testTerminator);
rgrover1 0:0b799af9d58e 341 }
rgrover1 0:0b799af9d58e 342
rgrover1 0:0b799af9d58e 343 void UtestShell::fail(const char *text, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 344 {
rgrover1 0:0b799af9d58e 345 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 346 failWith(FailFailure(this, fileName, lineNumber, text), testTerminator);
rgrover1 0:0b799af9d58e 347 }
rgrover1 0:0b799af9d58e 348
rgrover1 0:0b799af9d58e 349 void UtestShell::assertCstrEqual(const char* expected, const char* actual, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 350 {
rgrover1 0:0b799af9d58e 351 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 352 if (actual == 0 && expected == 0) return;
rgrover1 0:0b799af9d58e 353 if (actual == 0 || expected == 0)
rgrover1 0:0b799af9d58e 354 failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual), testTerminator);
rgrover1 0:0b799af9d58e 355 if (PlatformSpecificStrCmp(expected, actual) != 0)
rgrover1 0:0b799af9d58e 356 failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual), testTerminator);
rgrover1 0:0b799af9d58e 357 }
rgrover1 0:0b799af9d58e 358
rgrover1 0:0b799af9d58e 359 void UtestShell::assertCstrNoCaseEqual(const char* expected, const char* actual, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 360 {
rgrover1 0:0b799af9d58e 361 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 362 if (actual == 0 && expected == 0) return;
rgrover1 0:0b799af9d58e 363 if (actual == 0 || expected == 0)
rgrover1 0:0b799af9d58e 364 failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 365 if (!SimpleString(expected).equalsNoCase(actual))
rgrover1 0:0b799af9d58e 366 failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 367 }
rgrover1 0:0b799af9d58e 368
rgrover1 0:0b799af9d58e 369 void UtestShell::assertCstrContains(const char* expected, const char* actual, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 370 {
rgrover1 0:0b799af9d58e 371 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 372 if (actual == 0 && expected == 0) return;
rgrover1 0:0b799af9d58e 373 if(actual == 0 || expected == 0)
rgrover1 0:0b799af9d58e 374 failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 375 if (!SimpleString(actual).contains(expected))
rgrover1 0:0b799af9d58e 376 failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 377 }
rgrover1 0:0b799af9d58e 378
rgrover1 0:0b799af9d58e 379 void UtestShell::assertCstrNoCaseContains(const char* expected, const char* actual, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 380 {
rgrover1 0:0b799af9d58e 381 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 382 if (actual == 0 && expected == 0) return;
rgrover1 0:0b799af9d58e 383 if(actual == 0 || expected == 0)
rgrover1 0:0b799af9d58e 384 failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 385 if (!SimpleString(actual).containsNoCase(expected))
rgrover1 0:0b799af9d58e 386 failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
rgrover1 0:0b799af9d58e 387 }
rgrover1 0:0b799af9d58e 388
rgrover1 0:0b799af9d58e 389 void UtestShell::assertLongsEqual(long expected, long actual, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 390 {
rgrover1 0:0b799af9d58e 391 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 392 if (expected != actual)
rgrover1 0:0b799af9d58e 393 failWith(LongsEqualFailure (this, fileName, lineNumber, expected, actual), testTerminator);
rgrover1 0:0b799af9d58e 394 }
rgrover1 0:0b799af9d58e 395
Rohit Grover 1:4769360130ed 396 void UtestShell::assertUnsignedLongsEqual(unsigned long expected, unsigned long actual, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
Rohit Grover 1:4769360130ed 397 {
Rohit Grover 1:4769360130ed 398 getTestResult()->countCheck();
Rohit Grover 1:4769360130ed 399 if (expected != actual)
Rohit Grover 1:4769360130ed 400 failWith(UnsignedLongsEqualFailure (this, fileName, lineNumber, expected, actual), testTerminator);
Rohit Grover 1:4769360130ed 401 }
Rohit Grover 1:4769360130ed 402
rgrover1 0:0b799af9d58e 403 void UtestShell::assertPointersEqual(const void* expected, const void* actual, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 404 {
rgrover1 0:0b799af9d58e 405 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 406 if (expected != actual)
rgrover1 0:0b799af9d58e 407 failWith(EqualsFailure(this, fileName, lineNumber, StringFrom(expected), StringFrom(actual)));
rgrover1 0:0b799af9d58e 408 }
rgrover1 0:0b799af9d58e 409
rgrover1 0:0b799af9d58e 410 void UtestShell::assertDoublesEqual(double expected, double actual, double threshold, const char* fileName, int lineNumber, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 411 {
rgrover1 0:0b799af9d58e 412 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 413 if (!doubles_equal(expected, actual, threshold))
rgrover1 0:0b799af9d58e 414 failWith(DoublesEqualFailure(this, fileName, lineNumber, expected, actual, threshold), testTerminator);
rgrover1 0:0b799af9d58e 415 }
rgrover1 0:0b799af9d58e 416
rgrover1 0:0b799af9d58e 417 void UtestShell::assertEquals(bool failed, const char* expected, const char* actual, const char* file, int line, const TestTerminator& testTerminator)
rgrover1 0:0b799af9d58e 418 {
rgrover1 0:0b799af9d58e 419 getTestResult()->countCheck();
rgrover1 0:0b799af9d58e 420 if (failed)
rgrover1 0:0b799af9d58e 421 failWith(CheckEqualFailure(this, file, line, expected, actual), testTerminator);
rgrover1 0:0b799af9d58e 422 }
rgrover1 0:0b799af9d58e 423
rgrover1 0:0b799af9d58e 424
rgrover1 0:0b799af9d58e 425 void UtestShell::print(const char *text, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 426 {
rgrover1 0:0b799af9d58e 427 SimpleString stringToPrint = "\n";
rgrover1 0:0b799af9d58e 428 stringToPrint += fileName;
rgrover1 0:0b799af9d58e 429 stringToPrint += ":";
rgrover1 0:0b799af9d58e 430 stringToPrint += StringFrom(lineNumber);
rgrover1 0:0b799af9d58e 431 stringToPrint += " ";
rgrover1 0:0b799af9d58e 432 stringToPrint += text;
rgrover1 0:0b799af9d58e 433 getTestResult()->print(stringToPrint.asCharString());
rgrover1 0:0b799af9d58e 434 }
rgrover1 0:0b799af9d58e 435
rgrover1 0:0b799af9d58e 436 void UtestShell::print(const SimpleString& text, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 437 {
rgrover1 0:0b799af9d58e 438 print(text.asCharString(), fileName, lineNumber);
rgrover1 0:0b799af9d58e 439 }
rgrover1 0:0b799af9d58e 440
rgrover1 0:0b799af9d58e 441 TestResult* UtestShell::testResult_ = NULL;
rgrover1 0:0b799af9d58e 442 UtestShell* UtestShell::currentTest_ = NULL;
rgrover1 0:0b799af9d58e 443
rgrover1 0:0b799af9d58e 444 void UtestShell::setTestResult(TestResult* result)
rgrover1 0:0b799af9d58e 445 {
rgrover1 0:0b799af9d58e 446 testResult_ = result;
rgrover1 0:0b799af9d58e 447 }
rgrover1 0:0b799af9d58e 448
rgrover1 0:0b799af9d58e 449 void UtestShell::setCurrentTest(UtestShell* test)
rgrover1 0:0b799af9d58e 450 {
rgrover1 0:0b799af9d58e 451 currentTest_ = test;
rgrover1 0:0b799af9d58e 452 }
rgrover1 0:0b799af9d58e 453
rgrover1 0:0b799af9d58e 454 TestResult* UtestShell::getTestResult()
rgrover1 0:0b799af9d58e 455 {
rgrover1 0:0b799af9d58e 456 if (testResult_ == NULL)
rgrover1 0:0b799af9d58e 457 return &OutsideTestRunnerUTest::instance().getTestResult();
rgrover1 0:0b799af9d58e 458 return testResult_;
rgrover1 0:0b799af9d58e 459 }
rgrover1 0:0b799af9d58e 460
rgrover1 0:0b799af9d58e 461 UtestShell* UtestShell::getCurrent()
rgrover1 0:0b799af9d58e 462 {
rgrover1 0:0b799af9d58e 463 if (currentTest_ == NULL)
rgrover1 0:0b799af9d58e 464 return &OutsideTestRunnerUTest::instance();
rgrover1 0:0b799af9d58e 465 return currentTest_;
rgrover1 0:0b799af9d58e 466 }
rgrover1 0:0b799af9d58e 467
rgrover1 0:0b799af9d58e 468
rgrover1 0:0b799af9d58e 469 ExecFunctionTestShell::~ExecFunctionTestShell()
rgrover1 0:0b799af9d58e 470 {
rgrover1 0:0b799af9d58e 471 }
rgrover1 0:0b799af9d58e 472
rgrover1 0:0b799af9d58e 473 ////////////// Utest ////////////
rgrover1 0:0b799af9d58e 474
rgrover1 0:0b799af9d58e 475 Utest::Utest()
rgrover1 0:0b799af9d58e 476 {
rgrover1 0:0b799af9d58e 477 }
rgrover1 0:0b799af9d58e 478
rgrover1 0:0b799af9d58e 479 Utest::~Utest()
rgrover1 0:0b799af9d58e 480 {
rgrover1 0:0b799af9d58e 481 }
rgrover1 0:0b799af9d58e 482
rgrover1 0:0b799af9d58e 483 #if CPPUTEST_USE_STD_CPP_LIB
rgrover1 0:0b799af9d58e 484
rgrover1 0:0b799af9d58e 485 void Utest::run()
rgrover1 0:0b799af9d58e 486 {
rgrover1 0:0b799af9d58e 487 try {
rgrover1 0:0b799af9d58e 488 if (PlatformSpecificSetJmp(helperDoTestSetup, this)) {
rgrover1 0:0b799af9d58e 489 PlatformSpecificSetJmp(helperDoTestBody, this);
rgrover1 0:0b799af9d58e 490 }
rgrover1 0:0b799af9d58e 491 }
rgrover1 0:0b799af9d58e 492 catch (CppUTestFailedException&)
rgrover1 0:0b799af9d58e 493 {
rgrover1 0:0b799af9d58e 494 PlatformSpecificRestoreJumpBuffer();
rgrover1 0:0b799af9d58e 495 }
rgrover1 0:0b799af9d58e 496
rgrover1 0:0b799af9d58e 497 try {
rgrover1 0:0b799af9d58e 498 PlatformSpecificSetJmp(helperDoTestTeardown, this);
rgrover1 0:0b799af9d58e 499 }
rgrover1 0:0b799af9d58e 500 catch (CppUTestFailedException&)
rgrover1 0:0b799af9d58e 501 {
rgrover1 0:0b799af9d58e 502 PlatformSpecificRestoreJumpBuffer();
rgrover1 0:0b799af9d58e 503 }
rgrover1 0:0b799af9d58e 504
rgrover1 0:0b799af9d58e 505 }
rgrover1 0:0b799af9d58e 506 #else
rgrover1 0:0b799af9d58e 507
rgrover1 0:0b799af9d58e 508 void Utest::run()
rgrover1 0:0b799af9d58e 509 {
rgrover1 0:0b799af9d58e 510 if (PlatformSpecificSetJmp(helperDoTestSetup, this)) {
rgrover1 0:0b799af9d58e 511 PlatformSpecificSetJmp(helperDoTestBody, this);
rgrover1 0:0b799af9d58e 512 }
rgrover1 0:0b799af9d58e 513 PlatformSpecificSetJmp(helperDoTestTeardown, this);
rgrover1 0:0b799af9d58e 514 }
rgrover1 0:0b799af9d58e 515
rgrover1 0:0b799af9d58e 516 #endif
rgrover1 0:0b799af9d58e 517
rgrover1 0:0b799af9d58e 518 void Utest::setup()
rgrover1 0:0b799af9d58e 519 {
rgrover1 0:0b799af9d58e 520 }
rgrover1 0:0b799af9d58e 521
rgrover1 0:0b799af9d58e 522 void Utest::testBody()
rgrover1 0:0b799af9d58e 523 {
rgrover1 0:0b799af9d58e 524 }
rgrover1 0:0b799af9d58e 525
rgrover1 0:0b799af9d58e 526 void Utest::teardown()
rgrover1 0:0b799af9d58e 527 {
rgrover1 0:0b799af9d58e 528 }
rgrover1 0:0b799af9d58e 529
rgrover1 0:0b799af9d58e 530
rgrover1 0:0b799af9d58e 531 ////////////// NullTestShell ////////////
rgrover1 0:0b799af9d58e 532
rgrover1 0:0b799af9d58e 533
rgrover1 0:0b799af9d58e 534 NullTestShell::NullTestShell() :
rgrover1 0:0b799af9d58e 535 UtestShell("NullGroup", "NullName", "NullFile", -1, 0)
rgrover1 0:0b799af9d58e 536 {
rgrover1 0:0b799af9d58e 537 }
rgrover1 0:0b799af9d58e 538
rgrover1 0:0b799af9d58e 539 NullTestShell::NullTestShell(const char* fileName, int lineNumber) :
rgrover1 0:0b799af9d58e 540 UtestShell("NullGroup", "NullName", fileName, lineNumber, 0)
rgrover1 0:0b799af9d58e 541 {
rgrover1 0:0b799af9d58e 542 }
rgrover1 0:0b799af9d58e 543
rgrover1 0:0b799af9d58e 544 NullTestShell::~NullTestShell()
rgrover1 0:0b799af9d58e 545 {
rgrover1 0:0b799af9d58e 546 }
rgrover1 0:0b799af9d58e 547
rgrover1 0:0b799af9d58e 548 NullTestShell& NullTestShell::instance()
rgrover1 0:0b799af9d58e 549 {
rgrover1 0:0b799af9d58e 550 static NullTestShell _instance;
rgrover1 0:0b799af9d58e 551 return _instance;
rgrover1 0:0b799af9d58e 552 }
rgrover1 0:0b799af9d58e 553
rgrover1 0:0b799af9d58e 554 int NullTestShell::countTests()
rgrover1 0:0b799af9d58e 555 {
rgrover1 0:0b799af9d58e 556 return 0;
rgrover1 0:0b799af9d58e 557 }
rgrover1 0:0b799af9d58e 558
rgrover1 0:0b799af9d58e 559 UtestShell* NullTestShell::getNext() const
rgrover1 0:0b799af9d58e 560 {
rgrover1 0:0b799af9d58e 561 return &instance();
rgrover1 0:0b799af9d58e 562 }
rgrover1 0:0b799af9d58e 563
rgrover1 0:0b799af9d58e 564 bool NullTestShell::isNull() const
rgrover1 0:0b799af9d58e 565 {
rgrover1 0:0b799af9d58e 566 return true;
rgrover1 0:0b799af9d58e 567 }
rgrover1 0:0b799af9d58e 568
rgrover1 0:0b799af9d58e 569 void NullTestShell::testBody()
rgrover1 0:0b799af9d58e 570 {
rgrover1 0:0b799af9d58e 571 }
rgrover1 0:0b799af9d58e 572
rgrover1 0:0b799af9d58e 573
rgrover1 0:0b799af9d58e 574 /////////////////// Terminators
rgrover1 0:0b799af9d58e 575
rgrover1 0:0b799af9d58e 576 TestTerminator::~TestTerminator()
rgrover1 0:0b799af9d58e 577 {
rgrover1 0:0b799af9d58e 578 }
rgrover1 0:0b799af9d58e 579
rgrover1 0:0b799af9d58e 580 void NormalTestTerminator::exitCurrentTest() const
rgrover1 0:0b799af9d58e 581 {
rgrover1 0:0b799af9d58e 582 #if CPPUTEST_USE_STD_CPP_LIB
rgrover1 0:0b799af9d58e 583 throw CppUTestFailedException();
rgrover1 0:0b799af9d58e 584 #else
rgrover1 0:0b799af9d58e 585 TestTerminatorWithoutExceptions().exitCurrentTest();
rgrover1 0:0b799af9d58e 586 #endif
rgrover1 0:0b799af9d58e 587 }
rgrover1 0:0b799af9d58e 588
rgrover1 0:0b799af9d58e 589 NormalTestTerminator::~NormalTestTerminator()
rgrover1 0:0b799af9d58e 590 {
rgrover1 0:0b799af9d58e 591 }
rgrover1 0:0b799af9d58e 592
rgrover1 0:0b799af9d58e 593 void TestTerminatorWithoutExceptions::exitCurrentTest() const
rgrover1 0:0b799af9d58e 594 {
rgrover1 0:0b799af9d58e 595 PlatformSpecificLongJmp();
rgrover1 0:0b799af9d58e 596 }
rgrover1 0:0b799af9d58e 597
rgrover1 0:0b799af9d58e 598 TestTerminatorWithoutExceptions::~TestTerminatorWithoutExceptions()
rgrover1 0:0b799af9d58e 599 {
rgrover1 0:0b799af9d58e 600 }
rgrover1 0:0b799af9d58e 601
rgrover1 0:0b799af9d58e 602 //////////////////// ExecFunctionTest
rgrover1 0:0b799af9d58e 603
rgrover1 0:0b799af9d58e 604 ExecFunctionTest::ExecFunctionTest(ExecFunctionTestShell* shell)
rgrover1 0:0b799af9d58e 605 : shell_(shell)
rgrover1 0:0b799af9d58e 606 {
rgrover1 0:0b799af9d58e 607 }
rgrover1 0:0b799af9d58e 608
rgrover1 0:0b799af9d58e 609 void ExecFunctionTest::testBody()
rgrover1 0:0b799af9d58e 610 {
rgrover1 0:0b799af9d58e 611 if (shell_->testFunction_) shell_->testFunction_();
rgrover1 0:0b799af9d58e 612 }
rgrover1 0:0b799af9d58e 613
rgrover1 0:0b799af9d58e 614 void ExecFunctionTest::setup()
rgrover1 0:0b799af9d58e 615 {
rgrover1 0:0b799af9d58e 616 if (shell_->setup_) shell_->setup_();
rgrover1 0:0b799af9d58e 617 }
rgrover1 0:0b799af9d58e 618
rgrover1 0:0b799af9d58e 619 void ExecFunctionTest::teardown()
rgrover1 0:0b799af9d58e 620 {
rgrover1 0:0b799af9d58e 621 if (shell_->teardown_) shell_->teardown_();
rgrover1 0:0b799af9d58e 622 }
rgrover1 0:0b799af9d58e 623
rgrover1 0:0b799af9d58e 624 /////////////// IgnoredUtestShell /////////////
rgrover1 0:0b799af9d58e 625 IgnoredUtestShell::IgnoredUtestShell()
rgrover1 0:0b799af9d58e 626 {
rgrover1 0:0b799af9d58e 627 }
rgrover1 0:0b799af9d58e 628
rgrover1 0:0b799af9d58e 629 IgnoredUtestShell::~IgnoredUtestShell()
rgrover1 0:0b799af9d58e 630 {
rgrover1 0:0b799af9d58e 631 }
rgrover1 0:0b799af9d58e 632
rgrover1 0:0b799af9d58e 633 const char* IgnoredUtestShell::getProgressIndicator() const
rgrover1 0:0b799af9d58e 634 {
rgrover1 0:0b799af9d58e 635 return "!";
rgrover1 0:0b799af9d58e 636 }
rgrover1 0:0b799af9d58e 637
rgrover1 0:0b799af9d58e 638 SimpleString IgnoredUtestShell::getMacroName() const
rgrover1 0:0b799af9d58e 639 {
rgrover1 0:0b799af9d58e 640 return "IGNORE_TEST";
rgrover1 0:0b799af9d58e 641 }
rgrover1 0:0b799af9d58e 642
rgrover1 0:0b799af9d58e 643 void IgnoredUtestShell::runOneTest(TestPlugin* /* plugin */, TestResult& result)
rgrover1 0:0b799af9d58e 644 {
rgrover1 0:0b799af9d58e 645 result.countIgnored();
rgrover1 0:0b799af9d58e 646 }
rgrover1 0:0b799af9d58e 647
rgrover1 0:0b799af9d58e 648
rgrover1 0:0b799af9d58e 649 ////////////// TestInstaller ////////////
rgrover1 0:0b799af9d58e 650
rgrover1 0:0b799af9d58e 651 TestInstaller::TestInstaller(UtestShell& shell, const char* groupName, const char* testName, const char* fileName, int lineNumber)
rgrover1 0:0b799af9d58e 652 {
rgrover1 0:0b799af9d58e 653 shell.setGroupName(groupName);
rgrover1 0:0b799af9d58e 654 shell.setTestName(testName);
rgrover1 0:0b799af9d58e 655 shell.setFileName(fileName);
rgrover1 0:0b799af9d58e 656 shell.setLineNumber(lineNumber);
rgrover1 0:0b799af9d58e 657 TestRegistry::getCurrentRegistry()->addTest(&shell);
rgrover1 0:0b799af9d58e 658 }
rgrover1 0:0b799af9d58e 659
rgrover1 0:0b799af9d58e 660 TestInstaller::~TestInstaller()
rgrover1 0:0b799af9d58e 661 {
rgrover1 0:0b799af9d58e 662 }
rgrover1 0:0b799af9d58e 663
rgrover1 0:0b799af9d58e 664 void TestInstaller::unDo()
rgrover1 0:0b799af9d58e 665 {
rgrover1 0:0b799af9d58e 666 TestRegistry::getCurrentRegistry()->unDoLastAddTest();
rgrover1 0:0b799af9d58e 667 }