Web lists-archives.com

Re: Strategy for unit testing GTK+ applications in C

On 05/16/2015 11:45 AM, John Tall wrote:
> This time however I'm building an application, so it will already have
> its own main routine. I can't link my unit tests to the application
> because that would give me two main routines, the main entry point of
> the application and the main entry point of the unit test. So my
> question is how to construct the application so that I can test it
> with unit tests?

It is be possible to link an application in a way that does not call
main but a different function on start-up. I've never used them, but I
believe linker scripts can do that. It probably is less portable though.

> My first thought was to just build the entire application as a library
> and link the unit tests with it, then all I would need for the actual
> application would be a separate program that just creates an instance
> of my GtkApplication subclass and runs it. It would be small enough
> that it doesn't need any unit tests, and I could even link it
> statically when installing the program.

This is what I would do, but I don't know what is common -- other than
doing no unit testing at all, of course.

Attachment: signature.asc
Description: OpenPGP digital signature

gtk-list mailing list