r/C_Programming • • 19d 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
r/C_Programming • • 19d ago
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
7
u/QuraToop314 19d 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 15d ago edited 14d 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 19d ago
assert.h
2
u/Dependent_Bit7825 18d 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 18d 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 19d ago
Criterion, in my opinion it's better than unity
0
u/MiOursMiLoup 18d ago
Cmoka?
-1
u/Reasonable-Pay-8771 18d ago
min_unit.h
-4
u/[deleted] 18d ago
You can use gtest as well with C