{"id":15049239,"url":"https://github.com/goldsteinn/eztest","last_synced_at":"2026-02-01T16:33:24.546Z","repository":{"id":219042649,"uuid":"748014757","full_name":"goldsteinn/eztest","owner":"goldsteinn","description":"An Easy Unit Test Framework","archived":false,"fork":false,"pushed_at":"2025-11-15T23:23:14.000Z","size":489,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-16T01:21:48.205Z","etag":null,"topics":["c","c11","c17","c23","c99","ctest","cxx","cxx11","cxx14","cxx17","cxx20","cxx23","googletest","test-framework","testing","unittest","unittest-framework"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goldsteinn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-25T04:56:59.000Z","updated_at":"2025-11-15T23:23:17.000Z","dependencies_parsed_at":"2024-01-28T13:00:24.189Z","dependency_job_id":"83f4e60a-0173-428c-84ab-c4953bc323e1","html_url":"https://github.com/goldsteinn/eztest","commit_stats":null,"previous_names":["goldsteinn/eztest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/goldsteinn/eztest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldsteinn%2Feztest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldsteinn%2Feztest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldsteinn%2Feztest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldsteinn%2Feztest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goldsteinn","download_url":"https://codeload.github.com/goldsteinn/eztest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldsteinn%2Feztest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28982805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c11","c17","c23","c99","ctest","cxx","cxx11","cxx14","cxx17","cxx20","cxx23","googletest","test-framework","testing","unittest","unittest-framework"],"created_at":"2024-09-24T21:19:14.102Z","updated_at":"2026-02-01T16:33:24.530Z","avatar_url":"https://github.com/goldsteinn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EZTest\n\nAn easy to use and lightweight unit test framework for **C/C++** on\n**Linux** exported as a single header file\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\n\nThe API is made to mostly match\n[`GoogleTest`](https://github.com/google/googletest). For some\nprojects it can be a drop-in replacements, for others it won't work.\n\nThe key selling point, and primary motivating factor for writing\n`EZTest`, is that it will work out of the box with\n[`-fsanitizer=memory`](https://clang.llvm.org/docs/MemorySanitizer.html),\nas opposed to [`GoogleTest`](https://github.com/google/googletest)\nwhich requires re-building from source along with an\n[`-fsanitizer=memory`](https://clang.llvm.org/docs/MemorySanitizer.html)\nenabled [`libc++`](https://libcxx.llvm.org/) to work.\n\n\n\n- [1. Overview and Motivation](#1-overview-and-motivation)\n- [2. Installation](#2-installation)\n    - [2.1. Installing Using CMake](#21-installing-using-cmake)\n    - [2.2. Installing As Submodule](#22-installing-as-submodule)\n    - [2.3. Advanced Installation](#23-advanced-installation)\n- [3. Usage](#3-usage)\n    - [3.1. Namespacing](#31-namespacing)\n    - [3.2. Running Tests](#32-running-tests)\n    - [3.3. Test Setup](#33-test-setup)\n    - [3.4. Asserts and Expects](#34-asserts-and-expects)\n    - [3.5. Printing On Failure](#35-printing-on-failure)\n    - [3.6. Disabling Tests](#36-disabling-tests)\n    - [3.7. Difference From GoogleTest](#37-difference-from-googletest)\n- [4. Advanced Usage and Toggles](#4-advanced-usage-and-toggles)\n    - [4.1. Behavioral Toggles](#41-behavioral-toggles)\n    - [4.2. Compilation Toggles](#42-compilation-toggles)\n- [5. System Requirements](#5-system-requirements)\n    - [5.1. Operating System](#51-operating-system)\n    - [5.2. Compiler](#52-compiler)\n    - [5.3. Language](#53-language)\n    - [5.4. Architecture](#54-architecture)\n- [6. Developer Info](#6-developer-info)\n    - [6.1. EZTest Source](#61-eztest-source)\n    - [6.2. EZTest Header Generation](#62-eztest-header-generation)\n    - [6.3. Internal Testing of EZTest](#63-internal-testing-of-eztest)\n## 1. Overview and Motivation\n\n\nThe general motivating factor for `EZTest` is to be an alternative to\n[`GoogleTest`](https://github.com/google/googletest) with a few\nimportant distinguishing characteristics.\n\n1. `EZTest` tests do not link against the C++ runtime library\n   (`libc++.so`/`libstdc++.so`). This makes compiling the tests with\n   [`-fsanitizer=memory`](https://clang.llvm.org/docs/MemorySanitizer.html)\n   trivial.\n2. `EZTest` runs each test as its own process (using\n   [`fork`](https://man7.org/linux/man-pages/man2/fork.2.html)). This\n   allows for signal handling of buggy tests with clear error\n   messages. Further it isolates tests from one another preventing\n   potential corruption carrying over from one test to another.\n3. `EZTest` is packages as just a single header file and requires no\n   extra link/compilation steps to get working.\n\n## 2. Installation\n\n\u003c!-- See https://github.com/bernedom/SI/blob/main/doc/installation-guide.md --\u003e\nThe default installation location is `/usr/local`.\n\nKeep in mind, the only file necessary to get started is\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h),\nso feel free to just copy and include it as you see fit.\n\n### 2.1. Installing Using CMake\n\nClone the repository and run these commands in the cloned folder:\n```sh\nmkdir build \u0026\u0026 cd build\ncmake .. # Use -DCMAKE_INSTALL_PREFIX=\u003cyour_path\u003e to control the destination\ncmake --build . --target install\n```\n\nThen to use the installed library, add the following to your `cmake` project:\n\n```cmake\nfind_package(eztest REQUIRED)\ntarget_link_libraries(your_test_target eztest::eztest)\n```\n\n### 2.2. Installing As Submodule\n\nClone the repository and add the following to your `cmake` project\n```cmake\nadd_subdirectory(path/to/your/cloned/eztest)\ntarget_link_libraries(your_test_target eztest)\n```\n\n### 2.3. Advanced Installation\n\nThere are several toggles for modify how the\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\nis generated/installed.\n\nThese include\n```cmake\noption(\n  EZTEST_ULP_PRECISION\n  \"Int: Set float/double compare ULP bound\"\n  OFF)\noption(\n  EZTEST_FLOAT_ULP_PRECISION\n  \"Int: Set float compare ULP bound\"\n  OFF)\noption(\n  EZTEST_DOUBLE_ULP_PRECISION\n  \"Int: Set double compare ULP bound\"\n  OFF)\noption(\n  EZTEST_DISABLE_WARNINGS\n  \"Bool: Set/unset to configure whether warnings are supressed with pragmas\"\n  OFF)\noption(\n  EZTEST_DISABLE_LINTS\n  \"Bool: Set/unset to configure whether lints are supressed with comments\"\n  OFF)\noption(\n  EZTEST_STRICT_NAMESPACE\n  \"Bool: Set/unset to configure whether generic TEST/ASSERT/EXPECT macros are defined\"\n  OFF)\n```\n\nand can be set during the installation setup. All of these other than\n`EZTEST_DISABLE_LINTS` have corresponding macros (see [4. Advanced\nUsage and Toggles](#4-advanced-usage-and-toggles)). The\n`EZTEST_DISABLE_LINTS` option will determine whether `/* NOLINT* */`\ndirectives are transferred from the source code to the header during\ngeneration. If you want to ensure certain code characteristics using\n`clang-tidy` including in the `EZTest` header, set\n`-DEZTEST_DISABLE_LINTS=ON` during installation.\n\n## 3. Usage\n\nThe API is similiar to that of\n[`GoogleTest`](https://github.com/google/googletest) but there are\nsome key distinction.\n\n### 3.1. Namespacing\n\nAll symbols and macros defined in\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\nare prefixed `eztest` or `EZTEST`. Furthermore if compiling with `C++`\nall symbols are inside the `eztest::` namespace. Assuming your code\nhas no symbols/macros begining with `eztest` or `EZTEST` and/or no\nsymbols in the `eztest::` namespace, there should be no symbol\nconflicts when using `EZTest`.\n\n### 3.2. Running Tests\n\n1. Include [`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h) in your test file\n2. Build your test executable\n3. Run the resulting executable.\n\nFor example take the following `test.cc`\n\n```C\n/* eztest.h contains `main`.  */\n#include \"eztest/eztest.h\"\n\nTEST(foo, bar) {\n    ASSERT_EQ(0, 0);\n}\n```\n\nTo run the test(s) we would do the following:\n```sh\nclang++ test.cc -O3 -o test\n./test\n```\n\n### 3.3. Test Setup\n\nTests are created with the following macros:\n- `TEST(suite, name)`\n- `TEST_TIMED(suite, name, timeout_in_milliseconds)`\n\nThe usage is identical to\n[`GoogleTest`](https://github.com/google/googletest) i.e:\n\n```C\nTEST(my_suite, my_test) {\n   /* Test code goes here... */\n}\n```\n\n### 3.4. Asserts and Expects\n\nThere are assertions / expect statements a variety of different\nchecks. The difference between an `ASSERT` check and `EXPECT` check,\nis that if an `ASSERT` check fails, the test will end\nimmediately. Alternatively if an `EXPECT` check fails, the test will\ncontinue running but will fail on termination.\n\n\n- `{ASSERT|EXPECT}_TRUE(arg:bool)`\n    - Checks the `arg` is `true`\n- `{ASSERT|EXPECT}_FALSE(arg:bool)`\n    - Checks the `arg` is `false`\n- `{ASSERT|EXPECT}_EQ(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs == rhs`\n- `{ASSERT|EXPECT}_NE(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs != rhs`\n- `{ASSERT|EXPECT}_LE(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs \u003c= rhs`\n- `{ASSERT|EXPECT}_LT(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs \u003c rhs`\n- `{ASSERT|EXPECT}_GE(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs \u003e= rhs`\n- `{ASSERT|EXPECT}_GT(lhs:anyT, rhs:anyT)`\n    - Checks that `lhs \u003e rhs`\n- `{ASSERT|EXPECT}_STREQ(lhs:str, rhs:str)`\n    - Checks that `strcmp(lhs, rhs) == 0`\n- `{ASSERT|EXPECT}_STRNE(lhs:str, rhs:str)`\n    - Checks that `strcmp(lhs, rhs) != 0`\n- `{ASSERT|EXPECT}_STRCASEEQ(lhs:str, rhs:str)`\n    - Checks that `strcasecmp(lhs, rhs) == 0`\n- `{ASSERT|EXPECT}_STRCASENE(lhs:str, rhs:str)`\n    - Checks that `strcasecmp(lhs, rhs) != 0`\n- `{ASSERT|EXPECT}_FLOAT_EQ(lhs:float, rhs:float)`\n    - Checks that `ULP_difference(lhs, rhs) \u003c Threshold`\n        - See more on [`ULP`](https://en.wikipedia.org/wiki/Unit_in_the_last_place).\n- `{ASSERT|EXPECT}_DOUBLE_EQ(lhs:double, rhs:double)`\n    - Checks that `ULP_difference(lhs, rhs) \u003c Threshold`\n- `{ASSERT|EXPECT}_NEAR(lhs:fp, rhs:fp, bound:fp)`\n    - Checks that `abs(lhs - rhs) \u003c= bound`\n\nIn the above:\n- `bool` is an type that supports the `!` operator.\n- `anyT` is any type that the specified operator is valid for.\n- `str` is one of the following:\n    - `char *`\n    - `std::string` (if using `C++`)\n    - `std::string_view` (if using `C++17` or newer)\n- `fp` is one of the following:\n    - `float`\n    - `double`\n\n### 3.5. Printing On Failure\n\nFailure messages that print the variables exist in the following\ncases:\n- You are using `C++`\n- You are using `C11` or newer with a compiler that supports the\n  [`__typeof__`](https://gcc.gnu.org/onlinedocs/gcc/Typeof.html)\n  extension.\n\nOtherwise, the failure message will only indicate the line number /\nvariables names that failed.\n\nIn additional to default failure messages, you can also optionally\ninclude [`printf`](https://en.cppreference.com/w/cpp/io/c/fprintf) as\noptional additional arguments to any `ASSERT`/`EXPECT` macro that will\nbe printed only on failure. For example:\n\n```C\n/* int a, b, c; */\nint d = a + b;\nASSERT_EQ(c, d, \"Something something %d + %d\\n\", a, b);\n```\n\n### 3.6. Disabling Tests\n\nTests can be disabled from running (but still built) by prefixing the\ntest name with `DISABLED_`.\n\nThis behaves exactly the same as\n[`GoogleTest`](https://github.com/google/googletest).\n\n\n### 3.7. Difference From GoogleTest\n\nThere are several key distinctions between the `EZTest` API and that\nof [`GoogleTest`](https://github.com/google/googletest).\n\nIn no particularly the notable differences are:\n\n*Support/fix is planned.\n\n1. *The following macros are unimplemented in `EZTest`:\n    - `TEST_F`\n    - `TEST_P`\n    - `SCOPED_TRACE`\n    - `{ASSERT|EXPECT}_THROW`\n    - `{ASSERT|EXPECT}_ANY_THROW`\n    - `{ASSERT|EXPECT}_NO_THROW`\n    - `{ASSERT|EXPECT}_NO_FATAL_FAILURE`\n    - `{ASSERT|EXPECT}_PRED1`\n    - `{ASSERT|EXPECT}_PRED2`\n    - `{ASSERT|EXPECT}_PRED3`\n    - `{ASSERT|EXPECT}_PRED4`\n    - `{ASSERT|EXPECT}_PRED5`\n\n2. There is no test\n   [`Fixture`](https://google.github.io/googletest/advanced.html) to\n   inherit from in `EZTest`.\n\n3. `EZTest` uses `C-style` printing as opposed to `C++-style` operator `\u003c\u003c`\n   printing.\n\n4. *There are no\n   [`DeathTests`](https://google.github.io/googletest/advanced.html) in `EZTest`.\n\n5. *There is an environment variable / commandline support in\n   `EZTest`. This is relevant to\n    - Test filtering.\n    - Test repeating\n    - Test shuffling\n    - Test listing\n    - etc...\n\n6. *There are no toggles for modify test printouts in `EZTest`.\n\n7. *There is no support for generating an XML/JSON files for the test results in `EZTest`.\n\n8. *There are slight differences in the printout format.\n\n9. *No global variables for changing behavior\n    - Instead there are some macros.\n\n## 4. Advanced Usage and Toggles\n\nThere are some macros that can be defined which will change the\nbehavior/compilation of\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h).\n\nFor the most part, the defaults should be fine.\n\n### 4.1. Behavioral Toggles\nThe following macros can be defined to change behavior.\n\n1. `EZTEST_ULP_PRECISION`\n    - `default:4`\n    - This will change the\n      [`ULP`](https://en.wikipedia.org/wiki/Unit_in_the_last_place)\n      for both `{ASSERT|EXPECT}_{FLOAT|DOUBLE}_EQ`\n2. `EZTEST_FLOAT_ULP_PRECISION`\n    - `default:EZTEST_ULP_PRECISION`\n    - This will change the\n      [`ULP`](https://en.wikipedia.org/wiki/Unit_in_the_last_place)\n      for both `{ASSERT|EXPECT}_FLOAT_EQ`\n3. `EZTEST_DOUBLE_ULP_PRECISION`\n    - `default:EZTEST_ULP_PRECISION`\n    - This will change the\n      [`ULP`](https://en.wikipedia.org/wiki/Unit_in_the_last_place)\n      for both `{ASSERT|EXPECT}_DOUBLE_EQ`\n4. `EZTEST_C_PRINT_ARGS`\n    - `default:1`\n    - If set to `0` and using the `C` language, `eztest` will stop\n      trying to print arguments on failure.\n5. `EZTEST_VERBOSITY`\n    - `default:0`\n    - Increase value to include more internal printouts (mostly just\n      non-fatal warnings).\n\n### 4.2. Compilation Toggles\nThe following macros can be defined to change compilation.\n\n1. `EZTEST_DISABLE_WARNINGS`\n    - `default:1`\n    - If set, `eztest` will enable\n      [`Pragmas`](https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html) to\n      disable known, inevitable, warnings. These warnings mostly only\n      show up if compiling with [`Clang's\n      -Weverything`](https://clang.llvm.org/docs/UsersManual.html#diagnostics-enable-everything)\n      or an excessive amount of `GCC` warnings. If compiling with\n      `-Wall -Wextra -Wpedantic` the only warning that may show up is\n      `-Wunused-function` depending on the set of `ASSERT`/`EXPECT`\n      checks used. The total set of disabled warnings are:\n        - `-Waggregate-returns`\n        - `-Wcxx98-compat-pedantic`\n        - `-Wcxx98-compat`\n        - `-Wdouble-promotion`\n        - `-Wfloat-equal`\n        - `-Wformat-nonliteral`\n        - `-Wglobal-constructors`\n        - `-Wpadded`\n        - `-Wunsafe-buffer-usage`\n        - `-Wunsafe-buffer-usage-in-libc-call`\n        - `-Wunused-function`\n        - `-Wunused-member-function`\n        - `-Wunused-result`\n        - `-Wunused-template`\n    - Note the `Pragmas` are used minimally and will never apply to\n      your own code.\n\n2. `EZTEST_STRICT_NAMESPACE`\n    - `default:0`\n    - If set, then general `{ASSERT|EXPECT}_*` and `TEST*` macros will\n      be prefixed with `EZTEST_`\n\n## 5. System Requirements\n\nThere are some system requirements. Some of these may not be\nhard-requirements, but at the very least they are untested.\n\n### 5.1. Operating System\n\n`Linux` is the only tested OS at the moment. It's probably that any\n`unix` based system would work.\n\n### 5.2. Compiler\n\n`GCC`/`Clang` are the only tested compilers are the moment.\n\n### 5.3. Language\n1. If `C`\n    - `C99` or newer\n    - Support for `__attribute__((constructor))`\n2. If `C++`\n    - `C++11` or newer\n\n### 5.4. Architecture\nIf compiling **without `posix`** specification\n    - `x86-64`\n    - `x86-32`\n    - `arm`\n    - `aarch64`\n    - `riscv64`\n    - `riscv32`\n\nOtherwise any target should work.\n\n\n## 6. Developer Info\n\n\n### 6.1. EZTest Source\n\nThe source code is located in\n[`src/eztest`](https://github.com/goldsteinn/eztest/tree/main/src/eztest).\n\nThe source code and includable\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\nfiles seperate. The actual\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\nheader is autogenerated. This is a convenience to make development\nsimpler.\n\n\n### 6.2. EZTest Header Generation\n\nTo generate the\n[`eztest.h`](https://github.com/goldsteinn/eztest/blob/main/include/eztest/eztest.h)\nheader file, we use the\n[`scripts/freeze.py`](https://github.com/goldsteinn/eztest/blob/main/scripts/freeze.py)\nscript.\n\nGenerally there is no need to invoke the script directly. It will\neither be invoked by `cmake` as needed for tests/installation, or by\nthe wrapper script\n[`quick-regen.py`](https://github.com/goldsteinn/eztest/blob/main/scripts/quick-regen.py).\n\n### 6.3. Internal Testing of EZTest\n\nTests are located in the\n[`tests`](https://github.com/goldsteinn/eztest/tree/main/tests)\ndirectory.\n\nTo build the tests you can run:\n```sh\nmkdir build \u0026\u0026 cd build\ncmake .. -DEZTEST_BUILD_TESTS=ON\nmake check-all # Run \"unit tests\"\nmake check-external # Run \"integration tests\"\nmake run-static-analysis # Run clang-tidy\n```\n\nThe general `cmake` compiler/flags/language arguments will also\napply. As well there are toolchain files are testing cross\ncompilation.\n\nTo see some examples of the internal tests usage see\n[.github/workflows/ci.yaml`](https://github.com/goldsteinn/eztest/blob/main/.github/workflows/ci.yaml).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldsteinn%2Feztest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoldsteinn%2Feztest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldsteinn%2Feztest/lists"}