libcheck / check

A unit testing framework for C
GNU Lesser General Public License v2.1
1.07k stars 210 forks source link

Is there a way how to read value of variable `_i` from loop test in checked fixtures? #256

Closed bletvaska closed 4 years ago

bletvaska commented 4 years ago

Hello

I use checked fixtures to open and close a file for a test and I use loop test to iterate the array of filenames. The current value of _i variable is very important for me to open the file at given index. Is there a way, how to get value of this variable from loop test in to fixture?

Anyway - the best TDD library, that we use to test problemsets of our students for several years already ;) But there is still something new to learn ;)

mirek

brarcher commented 4 years ago

Hm. The documentation says that the loop variable is only exposed to tests. The code says the same, namely that the loop index only makes it into the test and not the fixtures:

https://github.com/libcheck/check/blob/master/src/check_run.c#L497

So, the Check framework does not give a direct way to do it. Sorry.

bletvaska commented 4 years ago

Thanks. I know the documentation, I was just curious if I missed something.

Anyway - it's just one more line in the test calling such "fixture function". I can still replace the behaviour of traversing the array of files sequentially with random access. According to the test I just prefer the way to use every file of the list.

Thanks one more time.