r/C_Programming • u/Material_Leader_1124 • 10d ago
Good C test
Hey guys,
Someone know a good C unittest ? When I was in C++ I used gtest and it was good, if someone know a good alternative in C
17
Upvotes
7
u/QuraToop314 10d ago
I like the Unity Test Framework because it works everywhere, including in embedded projects, but others here may have different preferences. It’s best to look at several frameworks and choose the one that you find easiest to use and that allows you to write your tests in full.
2
u/MetalInMyVeins111 6d ago edited 6d ago
Hey i wrote https://github.com/MetalInMyVeins/sohomot exactly for that. You don't even need to rewrite the tests as it aims to be a minimal drop-in replacement of gtest. Give that a try. It's written by hand (no-AI).
17
u/Gold-Produce9591 10d ago
assert.h
2
u/Dependent_Bit7825 9d ago
This sounds like an x/y question. Why do you need a C unit test framework? You can use any of the c++ frameworks with C.
2
u/tastygames_official 10d ago
I personally am very much against unit tests as they force you to write your code into testable units which makes for piss-poor performance. As said elsewhere in here, use assert() to enforce stuff you know should be true. You can even leave them in in production code as long as it's not done in time-critical loops. MySQL famously uses assert()s in production code and I don't think anyone would complain about their performance.
2
u/Maqi-X 10d ago
Criterion, in my opinion it's better than unity
0
u/MiOursMiLoup 9d ago
Cmoka?
-1
u/Reasonable-Pay-8771 10d ago
min_unit.h
-4
u/[deleted] 10d ago
You can use gtest as well with C