diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..fd3cfbc
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,52 @@
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to
+
+project(utest)
+cmake_minimum_required(VERSION 2.8.7)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+add_executable(utest_test
+ ../utest.h
+ main.c
+ test.c
+ test.cpp
+)
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set_source_files_properties(test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "/Wall /WX /wd4514"
+ )
+else()
+ message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endif()
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..fd3cfbc
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,52 @@
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to
+
+project(utest)
+cmake_minimum_required(VERSION 2.8.7)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+add_executable(utest_test
+ ../utest.h
+ main.c
+ test.c
+ test.cpp
+)
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set_source_files_properties(test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "/Wall /WX /wd4514"
+ )
+else()
+ message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endif()
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..f6c50cc
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,28 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+UTEST_MAIN()
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..fd3cfbc
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,52 @@
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to
+
+project(utest)
+cmake_minimum_required(VERSION 2.8.7)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+add_executable(utest_test
+ ../utest.h
+ main.c
+ test.c
+ test.cpp
+)
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set_source_files_properties(test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "/Wall /WX /wd4514"
+ )
+else()
+ message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endif()
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..f6c50cc
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,28 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+UTEST_MAIN()
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..9a553e2
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,94 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+TESTCASE(c, ASSERT_TRUE) {
+ ASSERT_TRUE(1);
+}
+
+TESTCASE(c, ASSERT_FALSE) {
+ ASSERT_FALSE(0);
+}
+
+TESTCASE(c, ASSERT_EQ) {
+ ASSERT_EQ(1, 1);
+}
+
+TESTCASE(c, ASSERT_NE) {
+ ASSERT_NE(1, 2);
+}
+
+TESTCASE(c, ASSERT_LT) {
+ ASSERT_LT(1, 2);
+}
+
+TESTCASE(c, ASSERT_LE) {
+ ASSERT_LE(1, 1);
+ ASSERT_LE(1, 2);
+}
+
+TESTCASE(c, ASSERT_GT) {
+ ASSERT_GT(2, 1);
+}
+
+TESTCASE(c, ASSERT_GE) {
+ ASSERT_GE(1, 1);
+ ASSERT_GE(2, 1);
+}
+
+TESTCASE(c, EXPECT_TRUE) {
+ EXPECT_TRUE(1);
+}
+
+TESTCASE(c, EXPECT_FALSE) {
+ EXPECT_FALSE(0);
+}
+
+TESTCASE(c, EXPECT_EQ) {
+ EXPECT_EQ(1, 1);
+}
+
+TESTCASE(c, EXPECT_NE) {
+ EXPECT_NE(1, 2);
+}
+
+TESTCASE(c, EXPECT_LT) {
+ EXPECT_LT(1, 2);
+}
+
+TESTCASE(c, EXPECT_LE) {
+ EXPECT_LE(1, 1);
+ EXPECT_LE(1, 2);
+}
+
+TESTCASE(c, EXPECT_GT) {
+ EXPECT_GT(2, 1);
+}
+
+TESTCASE(c, EXPECT_GE) {
+ EXPECT_GE(1, 1);
+ EXPECT_GE(2, 1);
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..fd3cfbc
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,52 @@
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to
+
+project(utest)
+cmake_minimum_required(VERSION 2.8.7)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+add_executable(utest_test
+ ../utest.h
+ main.c
+ test.c
+ test.cpp
+)
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set_source_files_properties(test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "/Wall /WX /wd4514"
+ )
+else()
+ message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endif()
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..f6c50cc
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,28 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+UTEST_MAIN()
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..9a553e2
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,94 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+TESTCASE(c, ASSERT_TRUE) {
+ ASSERT_TRUE(1);
+}
+
+TESTCASE(c, ASSERT_FALSE) {
+ ASSERT_FALSE(0);
+}
+
+TESTCASE(c, ASSERT_EQ) {
+ ASSERT_EQ(1, 1);
+}
+
+TESTCASE(c, ASSERT_NE) {
+ ASSERT_NE(1, 2);
+}
+
+TESTCASE(c, ASSERT_LT) {
+ ASSERT_LT(1, 2);
+}
+
+TESTCASE(c, ASSERT_LE) {
+ ASSERT_LE(1, 1);
+ ASSERT_LE(1, 2);
+}
+
+TESTCASE(c, ASSERT_GT) {
+ ASSERT_GT(2, 1);
+}
+
+TESTCASE(c, ASSERT_GE) {
+ ASSERT_GE(1, 1);
+ ASSERT_GE(2, 1);
+}
+
+TESTCASE(c, EXPECT_TRUE) {
+ EXPECT_TRUE(1);
+}
+
+TESTCASE(c, EXPECT_FALSE) {
+ EXPECT_FALSE(0);
+}
+
+TESTCASE(c, EXPECT_EQ) {
+ EXPECT_EQ(1, 1);
+}
+
+TESTCASE(c, EXPECT_NE) {
+ EXPECT_NE(1, 2);
+}
+
+TESTCASE(c, EXPECT_LT) {
+ EXPECT_LT(1, 2);
+}
+
+TESTCASE(c, EXPECT_LE) {
+ EXPECT_LE(1, 1);
+ EXPECT_LE(1, 2);
+}
+
+TESTCASE(c, EXPECT_GT) {
+ EXPECT_GT(2, 1);
+}
+
+TESTCASE(c, EXPECT_GE) {
+ EXPECT_GE(1, 1);
+ EXPECT_GE(2, 1);
+}
diff --git a/test/test.cpp b/test/test.cpp
new file mode 100644
index 0000000..e4a5142
--- /dev/null
+++ b/test/test.cpp
@@ -0,0 +1,94 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+TESTCASE(cpp, ASSERT_TRUE) {
+ ASSERT_TRUE(1);
+}
+
+TESTCASE(cpp, ASSERT_FALSE) {
+ ASSERT_FALSE(0);
+}
+
+TESTCASE(cpp, ASSERT_EQ) {
+ ASSERT_EQ(1, 1);
+}
+
+TESTCASE(cpp, ASSERT_NE) {
+ ASSERT_NE(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_LT) {
+ ASSERT_LT(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_LE) {
+ ASSERT_LE(1, 1);
+ ASSERT_LE(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_GT) {
+ ASSERT_GT(2, 1);
+}
+
+TESTCASE(cpp, ASSERT_GE) {
+ ASSERT_GE(1, 1);
+ ASSERT_GE(2, 1);
+}
+
+TESTCASE(cpp, EXPECT_TRUE) {
+ EXPECT_TRUE(1);
+}
+
+TESTCASE(cpp, EXPECT_FALSE) {
+ EXPECT_FALSE(0);
+}
+
+TESTCASE(cpp, EXPECT_EQ) {
+ EXPECT_EQ(1, 1);
+}
+
+TESTCASE(cpp, EXPECT_NE) {
+ EXPECT_NE(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_LT) {
+ EXPECT_LT(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_LE) {
+ EXPECT_LE(1, 1);
+ EXPECT_LE(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_GT) {
+ EXPECT_GT(2, 1);
+}
+
+TESTCASE(cpp, EXPECT_GE) {
+ EXPECT_GE(1, 1);
+ EXPECT_GE(2, 1);
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f609285
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+ - CONFIGURATION=Debug
+ - CONFIGURATION=Release
+
+script:
+ - mkdir build
+ - cd build
+ - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../test
+ - make
+ - ./utest_test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..411b3da
--- /dev/null
+++ b/README.md
@@ -0,0 +1,288 @@
+# utest.h #
+
+[](https://ci.appveyor.com/project/sheredom/utest-h)
+
+[](https://travis-ci.org/sheredom/utest.h)
+
+A simple one header solution to unit testing for C/C++.
+
+## Usage ##
+
+Just include utest.h in your code!
+
+The current supported compilers are gcc, clang and msvc.
+
+The current tested compiler versions are gcc 4.8.2, clang 3.5 and MSVC 18.0.21005.1.
+
+## Design ##
+
+UTest is a single header library to enable all the fun of unit testing in C and C++. The library has been designed to provide an output similar to Google's googletest framework;
+
+ [==========] Running 1 test cases.
+ [ RUN ] foo.bar
+ [ OK ] foo.bar (631ns)
+ [==========] 1 test cases ran.
+ [ PASSED ] 1 tests.
+
+To define a test case to run, you can do the following;
+
+ #include "utest.h"
+
+ TESTCASE(foo, bar) {
+ ASSERT_TRUE(1);
+ }
+
+The TESTCASE macro takes two parameters - the first being the set that the test case belongs to, the second being the name of the test. This allows tests to be grouped for conveience.
+
+Matching what googletest has, we provide two variants of each of the error checking conditions - ASSERT's and EXPECT's. If an ASSERT fails, the test case will cease execution, and utest.h will continue with the next test case to be run. If an EXPECT fails, the remainder of the test case will still be executed, allowing for further checks to be carried out.
+
+We currently provide the following macros to be used within TESTCASE's.
+
+### ASSERT_TRUE(x) ###
+
+Asserts that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ ASSERT_TRUE(i); // pass!
+ ASSERT_TRUE(42); // pass!
+ ASSERT_TRUE(0); // fail!
+ }
+
+### ASSERT_FALSE(x) ###
+
+Asserts that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ ASSERT_FALSE(i); // pass!
+ ASSERT_FALSE(1); // fail!
+ }
+
+### ASSERT_EQ(x, y) ###
+
+Asserts that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ ASSERT_EQ(a, b); // pass!
+ ASSERT_EQ(a, 42); // pass!
+ ASSERT_EQ(42, b); // pass!
+ ASSERT_EQ(42, 42); // pass!
+ ASSERT_EQ(a, b + 1); // fail!
+ }
+
+### ASSERT_NE(x, y) ###
+
+Asserts that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_NE(a, b); // pass!
+ ASSERT_NE(a, 27); // pass!
+ ASSERT_NE(69, b); // pass!
+ ASSERT_NE(42, 13); // pass!
+ ASSERT_NE(a, 42); // fail!
+ }
+
+### ASSERT_LT(x, y) ###
+
+Asserts that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LT(a, b); // pass!
+ ASSERT_LT(a, 27); // pass!
+ ASSERT_LT(27, b); // pass!
+ ASSERT_LT(13, 42); // pass!
+ ASSERT_LT(b, a); // fail!
+ }
+
+### ASSERT_LE(x, y) ###
+
+Asserts that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ ASSERT_LE(a, b); // pass!
+ ASSERT_LE(a, 27); // pass!
+ ASSERT_LE(a, 13); // pass!
+ ASSERT_LE(27, b); // pass!
+ ASSERT_LE(42, b); // pass!
+ ASSERT_LE(13, 13); // pass!
+ ASSERT_LE(13, 42); // pass!
+ ASSERT_LE(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GT(a, b); // pass!
+ ASSERT_GT(a, 27); // pass!
+ ASSERT_GT(27, b); // pass!
+ ASSERT_GT(42, 13); // pass!
+ ASSERT_GT(b, a); // fail!
+ }
+
+### ASSERT_GT(x, y) ###
+
+Asserts that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ ASSERT_GE(a, b); // pass!
+ ASSERT_GE(a, 27); // pass!
+ ASSERT_GE(a, 13); // pass!
+ ASSERT_GE(27, b); // pass!
+ ASSERT_GE(42, b); // pass!
+ ASSERT_GE(13, 13); // pass!
+ ASSERT_GE(42, 13); // pass!
+ ASSERT_GE(b, a); // fail!
+ }
+
+### EXPECT_TRUE(x) ###
+
+Expects that x evaluates to true (EG. non-zero).
+
+ TESTCASE(foo, bar) {
+ int i = 1;
+ EXPECT_TRUE(i); // pass!
+ EXPECT_TRUE(42); // pass!
+ EXPECT_TRUE(0); // fail!
+ }
+
+### EXPECT_FALSE(x) ###
+
+Expects that x evaluates to false (EG. zero).
+
+ TESTCASE(foo, bar) {
+ int i = 0;
+ EXPECT_FALSE(i); // pass!
+ EXPECT_FALSE(1); // fail!
+ }
+
+### EXPECT_EQ(x, y) ###
+
+Expects that x and y are equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 42;
+ EXPECT_EQ(a, b); // pass!
+ EXPECT_EQ(a, 42); // pass!
+ EXPECT_EQ(42, b); // pass!
+ EXPECT_EQ(42, 42); // pass!
+ EXPECT_EQ(a, b + 1); // fail!
+ }
+
+### EXPECT_NE(x, y) ###
+
+Expects that x and y are not equal.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_NE(a, b); // pass!
+ EXPECT_NE(a, 27); // pass!
+ EXPECT_NE(69, b); // pass!
+ EXPECT_NE(42, 13); // pass!
+ EXPECT_NE(a, 42); // fail!
+ }
+
+### EXPECT_LT(x, y) ###
+
+Expects that x is less than y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LT(a, b); // pass!
+ EXPECT_LT(a, 27); // pass!
+ EXPECT_LT(27, b); // pass!
+ EXPECT_LT(13, 42); // pass!
+ EXPECT_LT(b, a); // fail!
+ }
+
+### EXPECT_LE(x, y) ###
+
+Expects that x is less than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 13;
+ int b = 42;
+ EXPECT_LE(a, b); // pass!
+ EXPECT_LE(a, 27); // pass!
+ EXPECT_LE(a, 13); // pass!
+ EXPECT_LE(27, b); // pass!
+ EXPECT_LE(42, b); // pass!
+ EXPECT_LE(13, 13); // pass!
+ EXPECT_LE(13, 42); // pass!
+ EXPECT_LE(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GT(a, b); // pass!
+ EXPECT_GT(a, 27); // pass!
+ EXPECT_GT(27, b); // pass!
+ EXPECT_GT(42, 13); // pass!
+ EXPECT_GT(b, a); // fail!
+ }
+
+### EXPECT_GT(x, y) ###
+
+Expects that x is greater than or equal to y.
+
+ TESTCASE(foo, bar) {
+ int a = 42;
+ int b = 13;
+ EXPECT_GE(a, b); // pass!
+ EXPECT_GE(a, 27); // pass!
+ EXPECT_GE(a, 13); // pass!
+ EXPECT_GE(27, b); // pass!
+ EXPECT_GE(42, b); // pass!
+ EXPECT_GE(13, 13); // pass!
+ EXPECT_GE(42, 13); // pass!
+ EXPECT_GE(b, a); // fail!
+ }
+
+## License ##
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..cb28fa9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,26 @@
+version: '{build}'
+
+skip_tags: true
+
+install: []
+
+environment:
+ matrix:
+ - VSVERSION: Visual Studio 11
+ - VSVERSION: Visual Studio 12
+
+platform:
+ - Win32
+ - x64
+
+configuration:
+ - Debug
+ - Release
+
+build_script:
+ - md build
+ - cd build
+ - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ../test
+ - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ../test
+ - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" utest.sln
+ - ./%CONFIGURATION%/utest_test.exe
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..fd3cfbc
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,52 @@
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to
+
+project(utest)
+cmake_minimum_required(VERSION 2.8.7)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+add_executable(utest_test
+ ../utest.h
+ main.c
+ test.c
+ test.cpp
+)
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set_source_files_properties(test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror"
+ )
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set_source_files_properties(main.c test.c test.cpp PROPERTIES
+ COMPILE_FLAGS "/Wall /WX /wd4514"
+ )
+else()
+ message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endif()
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..f6c50cc
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,28 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+UTEST_MAIN()
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..9a553e2
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,94 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+TESTCASE(c, ASSERT_TRUE) {
+ ASSERT_TRUE(1);
+}
+
+TESTCASE(c, ASSERT_FALSE) {
+ ASSERT_FALSE(0);
+}
+
+TESTCASE(c, ASSERT_EQ) {
+ ASSERT_EQ(1, 1);
+}
+
+TESTCASE(c, ASSERT_NE) {
+ ASSERT_NE(1, 2);
+}
+
+TESTCASE(c, ASSERT_LT) {
+ ASSERT_LT(1, 2);
+}
+
+TESTCASE(c, ASSERT_LE) {
+ ASSERT_LE(1, 1);
+ ASSERT_LE(1, 2);
+}
+
+TESTCASE(c, ASSERT_GT) {
+ ASSERT_GT(2, 1);
+}
+
+TESTCASE(c, ASSERT_GE) {
+ ASSERT_GE(1, 1);
+ ASSERT_GE(2, 1);
+}
+
+TESTCASE(c, EXPECT_TRUE) {
+ EXPECT_TRUE(1);
+}
+
+TESTCASE(c, EXPECT_FALSE) {
+ EXPECT_FALSE(0);
+}
+
+TESTCASE(c, EXPECT_EQ) {
+ EXPECT_EQ(1, 1);
+}
+
+TESTCASE(c, EXPECT_NE) {
+ EXPECT_NE(1, 2);
+}
+
+TESTCASE(c, EXPECT_LT) {
+ EXPECT_LT(1, 2);
+}
+
+TESTCASE(c, EXPECT_LE) {
+ EXPECT_LE(1, 1);
+ EXPECT_LE(1, 2);
+}
+
+TESTCASE(c, EXPECT_GT) {
+ EXPECT_GT(2, 1);
+}
+
+TESTCASE(c, EXPECT_GE) {
+ EXPECT_GE(1, 1);
+ EXPECT_GE(2, 1);
+}
diff --git a/test/test.cpp b/test/test.cpp
new file mode 100644
index 0000000..e4a5142
--- /dev/null
+++ b/test/test.cpp
@@ -0,0 +1,94 @@
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#include "utest.h"
+
+TESTCASE(cpp, ASSERT_TRUE) {
+ ASSERT_TRUE(1);
+}
+
+TESTCASE(cpp, ASSERT_FALSE) {
+ ASSERT_FALSE(0);
+}
+
+TESTCASE(cpp, ASSERT_EQ) {
+ ASSERT_EQ(1, 1);
+}
+
+TESTCASE(cpp, ASSERT_NE) {
+ ASSERT_NE(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_LT) {
+ ASSERT_LT(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_LE) {
+ ASSERT_LE(1, 1);
+ ASSERT_LE(1, 2);
+}
+
+TESTCASE(cpp, ASSERT_GT) {
+ ASSERT_GT(2, 1);
+}
+
+TESTCASE(cpp, ASSERT_GE) {
+ ASSERT_GE(1, 1);
+ ASSERT_GE(2, 1);
+}
+
+TESTCASE(cpp, EXPECT_TRUE) {
+ EXPECT_TRUE(1);
+}
+
+TESTCASE(cpp, EXPECT_FALSE) {
+ EXPECT_FALSE(0);
+}
+
+TESTCASE(cpp, EXPECT_EQ) {
+ EXPECT_EQ(1, 1);
+}
+
+TESTCASE(cpp, EXPECT_NE) {
+ EXPECT_NE(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_LT) {
+ EXPECT_LT(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_LE) {
+ EXPECT_LE(1, 1);
+ EXPECT_LE(1, 2);
+}
+
+TESTCASE(cpp, EXPECT_GT) {
+ EXPECT_GT(2, 1);
+}
+
+TESTCASE(cpp, EXPECT_GE) {
+ EXPECT_GE(1, 1);
+ EXPECT_GE(2, 1);
+}
diff --git a/utest.h b/utest.h
new file mode 100644
index 0000000..1dc7f86
--- /dev/null
+++ b/utest.h
@@ -0,0 +1,198 @@
+// The latest version of this library is available on GitHub;
+// https://github.com/sheredom/utest.h
+
+// This is free and unencumbered software released into the public domain.
+//
+// Anyone is free to copy, modify, publish, use, compile, sell, or
+// distribute this software, either in source code form or as a compiled
+// binary, for any purpose, commercial or non-commercial, and by any
+// means.
+//
+// In jurisdictions that recognize copyright laws, the author or authors
+// of this software dedicate any and all copyright interest in the
+// software to the public domain. We make this dedication for the benefit
+// of the public at large and to the detriment of our heirs and
+// successors. We intend this dedication to be an overt act of
+// relinquishment in perpetuity of all present and future rights to this
+// software under copyright law.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// For more information, please refer to
+
+#ifndef SHEREDOM_UTEST_H_INCLUDED
+#define SHEREDOM_UTEST_H_INCLUDED
+
+#include
+#include
+#include
+
+#ifdef _MSC_VER
+#else
+#include
+#endif
+
+#if defined(__cplusplus)
+#define UTEST_CAST(type, x) static_cast(x)
+#define UTEST_PTR_CAST(type, x) reinterpret_cast(x)
+#else
+#define UTEST_CAST(type, x) ((type)x)
+#define UTEST_PTR_CAST(type, x) ((type)x)
+#endif
+
+static inline long utest_ns() {
+#ifdef _MSC_VER
+#else
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return UTEST_CAST(long, ts.tv_sec) * 1000 * 1000 * 1000 + ts.tv_nsec;
+#endif
+}
+
+typedef void (*utest_testcase_t)(int *);
+
+struct utest_state_s {
+ utest_testcase_t *testcases;
+ const char **testcase_names;
+ size_t testcases_length;
+};
+
+#ifdef _MSC_VER
+#pragma section(".CRT$XCU", read)
+#define UTEST_INITIALIZER(f) \
+ static void __cdecl f(void); \
+ __declspec(allocate(".CRT$XCU")) void(__cdecl * f##_)(void) = f; \
+ static void __cdecl f(void)
+#else
+#define UTEST_INITIALIZER(f) \
+ static void f(void) __attribute__((constructor)); \
+ static void f(void)
+#endif
+
+#define UTEST_ASSERT(x, y, cond) \
+ if (!((x)cond(y))) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ return; \
+ }
+
+#define ASSERT_TRUE(x) \
+ if (!(x)) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ return; \
+ }
+
+#define ASSERT_FALSE(x) \
+ if (x) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ return; \
+ }
+
+#define ASSERT_EQ(x, y) UTEST_ASSERT(x, y, ==)
+#define ASSERT_NE(x, y) UTEST_ASSERT(x, y, !=)
+#define ASSERT_LT(x, y) UTEST_ASSERT(x, y, <)
+#define ASSERT_LE(x, y) UTEST_ASSERT(x, y, <=)
+#define ASSERT_GT(x, y) UTEST_ASSERT(x, y, >)
+#define ASSERT_GE(x, y) UTEST_ASSERT(x, y, >=)
+
+#define UTEST_EXPECT(x, y, cond) \
+ if (!((x)cond(y))) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ }
+
+#define EXPECT_TRUE(x) \
+ if (!(x)) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ }
+
+#define EXPECT_FALSE(x) \
+ if (x) { \
+ printf("%s:%u: Failure\n", __FILE__, __LINE__); \
+ *utest_result = 1; \
+ }
+
+#define EXPECT_EQ(x, y) UTEST_EXPECT(x, y, ==)
+#define EXPECT_NE(x, y) UTEST_EXPECT(x, y, !=)
+#define EXPECT_LT(x, y) UTEST_EXPECT(x, y, <)
+#define EXPECT_LE(x, y) UTEST_EXPECT(x, y, <=)
+#define EXPECT_GT(x, y) UTEST_EXPECT(x, y, >)
+#define EXPECT_GE(x, y) UTEST_EXPECT(x, y, >=)
+
+#define TESTCASE(set, name) \
+ extern struct utest_state_s utest_state; \
+ static void utest_run_##set##_##name(int *utest_result); \
+ UTEST_INITIALIZER(utest_register_##set##_##name) { \
+ const size_t index = utest_state.testcases_length++; \
+ utest_state.testcases = UTEST_PTR_CAST( \
+ utest_testcase_t *, \
+ realloc(utest_state.testcases, \
+ sizeof(utest_testcase_t) * utest_state.testcases_length)); \
+ utest_state.testcases[index] = &utest_run_##set##_##name; \
+ utest_state.testcase_names = UTEST_PTR_CAST( \
+ const char **, \
+ realloc(utest_state.testcase_names, \
+ sizeof(char *) * utest_state.testcases_length)); \
+ utest_state.testcase_names[index] = #set "." #name; \
+ } \
+ void utest_run_##set##_##name(int *utest_result)
+
+#define UTEST_MAIN() \
+ extern struct utest_state_s utest_state; \
+ struct utest_state_s utest_state; \
+ int main() { \
+ size_t failed = 0; \
+ size_t index = 0; \
+ size_t *failed_testcases = 0; \
+ size_t failed_testcases_length = 0; \
+ printf("\033[32m[==========]\033[0m Running %u test cases.\n", \
+ (unsigned)utest_state.testcases_length); \
+ for (index = 0; index < utest_state.testcases_length; index++) { \
+ int result = 0; \
+ long ns = 0; \
+ printf("\033[32m[ RUN ]\033[0m %s\n", \
+ utest_state.testcase_names[index]); \
+ ns = utest_ns(); \
+ utest_state.testcases[index](&result); \
+ ns = utest_ns() - ns; \
+ if (0 != result) { \
+ const size_t failed_testcase_index = failed_testcases_length++; \
+ failed_testcases = realloc(failed_testcases, \
+ sizeof(size_t) * failed_testcases_length); \
+ failed_testcases[failed_testcase_index] = index; \
+ failed++; \
+ printf("\033[31m[ FAILED ]\033[0m %s (%ldns)\n", \
+ utest_state.testcase_names[index], ns); \
+ } else { \
+ printf("\033[32m[ OK ]\033[0m %s (%ldns)\n", \
+ utest_state.testcase_names[index], ns); \
+ } \
+ } \
+ printf("\033[32m[==========]\033[0m %u test cases ran.\n", \
+ (unsigned)utest_state.testcases_length); \
+ printf("\033[32m[ PASSED ]\033[0m %u tests.\n", \
+ (unsigned)(utest_state.testcases_length - failed)); \
+ if (0 != failed) { \
+ printf("\033[31m[ FAILED ]\033[0m %u tests, listed below:\n", \
+ (unsigned)failed); \
+ for (index = 0; index < failed_testcases_length; index++) { \
+ printf("\033[31m[ FAILED ]\033[0m %s\n", \
+ utest_state.testcase_names[failed_testcases[index]]); \
+ } \
+ } \
+ free(failed_testcases); \
+ free(utest_state.testcases); \
+ free(utest_state.testcase_names); \
+ return (int)failed; \
+ }
+
+#endif // SHEREDOM_UTEST_H_INCLUDED