Skip to content

Commit 9eef32f

Browse files
committed
Added example code to unit test framework readme.
1 parent be49705 commit 9eef32f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,43 @@ This unit test framework provides a variety of features in a single library, inc
1212
* Override test output for function names and arguments.
1313
* Provide custom logging (replace stdio output).
1414
* Test for C++ exceptions.
15+
16+
## Code Examples
17+
18+
```cpp
19+
TEST(MyTest)
20+
{
21+
int a = 1;
22+
CHECK_TRUE(a == 1);
23+
24+
CHECK_EQUAL(a, 1);
25+
}
26+
27+
class MyClass
28+
{
29+
public:
30+
int MultiplyBy2(int i)
31+
{
32+
return i * 2;
33+
}
34+
35+
int Multiply(int i1, int i2)
36+
{
37+
return i1 * i2;
38+
}
39+
};
40+
41+
TEST_MEMBER_FUNCTION(MyClass, MultiplyBy2, int)
42+
{
43+
MyClass a;
44+
CHECK_EQUAL(a.MultiplyBy2(2), 4);
45+
}
46+
47+
TEST_MEMBER_FUNCTION(MyClass, Multiply, int_int)
48+
{
49+
TEST_OVERRIDE_ARGS("int, int");
50+
51+
MyClass a;
52+
CHECK_EQUAL(a.Multiply(2, 3), 6);
53+
}
54+
```

0 commit comments

Comments
 (0)