Skip to content

Commit 84b631e

Browse files
committed
Some very basic documentation
1 parent c4ad4af commit 84b631e

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

README.md

+41-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
This is a small and limited testing framework for C++.
1+
# FTEST - A Simple and Portable Testing Framework for C++
2+
I developed FTest to test [UTF-8 CPP library] (https://github.com/nemtrif/utfcpp). Previously, I was using [GoogleTest](https://google.github.io/googletest/) framework. Over time it became increasingly hard to use it with C++ 98. As I was using only a small subset of its features anyway, I decided to write a new testing framework. The important features of the framework are:
3+
4+
- Uses only C++ 98
5+
- Asserts are similar to a subset of Google Test's ones.
6+
- It is simple to get started with - just a single header file
7+
8+
You may want to use FTest if you want to quickly set-up a testing framework with an easy path to migrating to GoogleTest once you need more features.
9+
10+
Another use-case scenario for FTest is when you need to compile your code (including the tests) with C++ 98.
11+
12+
Or, you may just like the simplicity and small size of FTest and do not need the features offered by bigger testing frameworks.
13+
14+
15+
## A simple example
16+
To see real-life use of FTest, I suggest checking the tests directory of UTF-8 CPP project. That said, here is a simple example of using FTest:
17+
18+
```
19+
#include "ftest.h"
20+
21+
TEST(Simple, simple)
22+
{
23+
EXPECT_TRUE(true);
24+
}
25+
```
26+
27+
Save the content to a cpp file, compile it and run it. The output should look like:
28+
```
29+
[==========] Running 8 tests from 3 test cases.
30+
[----------] 1 tests from Simple
31+
[ RUN ] Simple.simple
32+
[ OK ] Simple.simple
33+
[----------] 1 tests from Simple
34+
[==========] 1 tests from 1 test cases ran.
35+
[ PASSED ] 1 tests.
36+
```
37+
38+
Some things to note:
39+
- The test program contains no `main()` function. It is provided by FTest, unless you define `F_TEST_NO_MAIN` before including ftest.h.
40+
- `TEST` macro takes two arguments: test case name ("Simple" in the previous example) and test name ("simple"). A test case is simply a group of related tests.
41+
- `EXPECT_TRUE` assertion is used to establish that a condition is true. FTest provides a limited number of assertions that can still be used to write simple and effective tests.

0 commit comments

Comments
 (0)