Questions tagged [c-criterion]

Use for questions about the unit test framework Snaipe/Criterion. Include the tag [c] or [c++] as applicable.

The Snaipe/Criterion unit test framework can be found on GitHub (https://github.com/Snaipe/Criterion). It claims to be a "dead-simple, yet extensible, C and C++ unit testing framework".

8 questions
4
votes
2 answers

Segfault trying to access a static string, but only sometimes depending on build environment

Wait, come back, I promise this isn't about uninitialized pointers! The problem I have written some unit tests using Criterion. The code under test doesn't matter; the problem crops up in the test itself. Here's a simplified version of the…
larsks
  • 277,717
  • 41
  • 399
  • 399
2
votes
0 answers

Criterion C header not found on macOS

I have the requirement to install Criterion (which is a testing framework for C) on my laptop running macOS. I use Homebrew daily so I thought it will be be easy to just run the brew command: brew install criterion But, every time I try to run a C…
drawbu
  • 81
  • 6
1
vote
1 answer

How to unit test a function that spawns child processes?

So after a LOT of trying. I've dumbed down everything to the following: The test case Test(minishell_loop, test_ls_exit) { t_minishell sheldon; ft_bzero(&sheldon, sizeof(t_minishell)); sheldon.command_line = ft_strdup("ls"); …
1
vote
0 answers

How to pass a string from main to macros ParameterizedTest without using global variable?

I've used the framework Criterion to write unit tests. I need to pass string from main to macros, that executes source code and check the result. I can't use global variable. Here is the full code: #include #include…
Sfdfsg
  • 127
  • 1
  • 11
0
votes
1 answer

C - Use valgrind to detect memory leaks and context error in my criterion unit tests

I'm trying to write unit tests for a C lib I've made. To do so I'm using the lib criterion. I would like to use valgrind to detect memory leaks and context error, when I run make test it generate a unit_test.o file that I can run throw valgrind and…
nem0z
  • 1,060
  • 1
  • 4
  • 17
0
votes
0 answers

How can I compile a criterion test using cmake and mingw on linux?

I have been trying to compile a small test on linux using cmake and mingw. However, the criterion.h library does not get linked when I cross-compile (regular compiling works fine). The toolchain file specifies mingw as the compiler. But I do not…
UndoingTech
  • 709
  • 3
  • 16
0
votes
1 answer

Criterion unit tests for memory addresses

Recently I've been recoding my own printf function, and with that, unit tests with the Criterion C library. When I tried testing the %p flag (printing the address of the pointer), I was just stuck there trying to figure out how to predict the memory…
pironc
  • 51
  • 1
  • 9
-9
votes
0 answers

How to parametrize a test suite/fixture in Criterion?

I'm building a Grid framework in C and just started using the Criterion framework for testing. The Grid framework provides many functions for creating different kinds of grids such as grid* new_row_major_double_grid() and grid* new_col_major_int().…
Mehdi Charife
  • 722
  • 1
  • 7
  • 22