Testing C code
Dave Gardner (8786) 27 posts |
Hi all, Firstly: is this a good forum for asking general programming questions about RISC OS, or is there a better section to post in? I’m getting started with C programming on RISC OS. I’m mostly new to C, but not new to building WIMP apps on RISC OS. To help me make sure each module of my C programme actually works, I’d like to write some unit tests. Does anyone have any examples of C unit tests for RISC OS? I’ve so far been using Steve Fryatt’s excellent programming in C tutorials 1, but this doesn’t go into unit testing. Ideally I’d like some example that adds say `MkTest` as an Obey file that then will run tests that use some friendly library that has already been ported to work nicely with the RISC OS development environment. A quick internet search turned up some frameworks for unit testing C, eg Unity 2, but obviously these haven’t been RISC-OS-ified so I was hoping there would be something that just works. 1. https://www.stevefryatt.org.uk/risc-os/wimp-prog |
Richard Walker (2090) 431 posts |
I have been wondering the same. I would like to be able to test various bits of USBJoystick. I was thinking of adding some test functions and *commands to run them as part of the module. Not great, but better than nothing. Some of my code, however, depends on things like vectors, USB comms or hardware activity. How can things like this be ‘mocked’? |
Dave Gardner (8786) 27 posts |
For my app, I’m creating modules that can be tested in isolation, and then trying to limit the code that talks to the OS. I think I’ll try out this, since it’s just one source/header file: |