Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix MODE parameter parsing #766
Sure! I'm happy to change this. Mainly I wanted tests to try to understand what was going on with the relevant functions and this was an easy way.
These tests use automake's test suite functionality. It is pretty flexible and there can be several test programs that will run. Since the one added here is a regular C program, we can also run it under valgrind and gdb and the like.
Another way I sometimes like to write tests like these is to have the test code in the actual source files guarded by ifdefs, and conditionally compile a main function in there. That way static functions can be tested.
What do you think? I'm not sure of the best way that would work here. We could consider test suite libraries/frameworks as well, if we wanted to think about making tests easier to write.
Seems mostly ok. Some style nitpicks. I'm allergic to strcats. Probably best to leave the test code out of this PR and make another one for it later.
BTW that test code could really benefit from some arrays of struct of [input, expected_target, expected_modes] or equivalent. Way too copypastey.
If I correctly understand what #601 is about all we have to do is preprocess the
Just my 0.02€
Thanks for the reviews. I force pushed stripping the ":" as suggested by @LemonBoy. I opted to strip it rather than replace it with a space as this function is used for more than mode parsing, and I don't know that all uses would ignore it. I'll move the tests to a separate PR.