Skip to content

Commit

Permalink
Adding documentation for CXXTEST_RUNNING
Browse files Browse the repository at this point in the history
  • Loading branch information
whart222 committed Apr 2, 2013
1 parent dff1393 commit 62c90a3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/examples/MyTestSuite12.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// MyTestSuite12.h
#include <cxxtest/TestSuite.h>

class MyTestSuite1 : public CxxTest::TestSuite
{
public:
void testAddition(void)
{
TS_ASSERT(1 + 1 > 1);
TS_ASSERT_EQUALS(1 + 1, 2);
}
};


#ifndef CXXTEST_RUNNING
#include <iostream>

int main(int argc, char *argv[])
{

std::cout << "Non-CxxTest stuff is happening now." << std::endl;

}
#endif
24 changes: 24 additions & 0 deletions doc/examples/buildRunner25.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

. GetGlobals.sh
export PATH=$CXXTEST/bin:$PATH

# @main:
cxxtestgen --error-printer -o runner.cpp MyTestSuite12.h
# @:main

# @compile:
g++ -o runner -I$CXXTEST runner.cpp
# @:compile

./runner > buildRunner.log
# @run:
./runner
# @:run
\rm -f runner runner.cpp


cp MyTestSuite12.h runner2.cpp
g++ -o runner2 -I$CXXTEST runner2.cpp
./runner2
\rm -f runner2 runner2.cpp
2 changes: 2 additions & 0 deletions doc/examples/buildRunner25.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Running cxxtest tests (1 test).OK!
Non-CxxTest stuff is happening now.
10 changes: 10 additions & 0 deletions doc/guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,16 @@ supports this with the +CXXTEST_STD()+ macro. For example,
handles the mapping of this to +cout+ or +std::cout+ depending on
options provided to +cxxtestgen+.
Finally, CxxTest defines the +CXXTEST_RUNNING+ preprocessor macro.
This can be used in a test header file to define code that is
executed when the header is not used in a test runner. For example:
[source,{cpp}]
-----
include::examples/MyTestSuite12.h[]
----
Note that test suites derived from +CxxTest::TestSuite+ class cannot
easily be built outside of the test runner.
Customizing Test Fixtures
Expand Down

0 comments on commit 62c90a3

Please sign in to comment.