Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Yeah, but it is also quite easy to implement a Test::More like testsuite in C with libtab (http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap). This library is pretty small, so you can ship it with your program. I just added a 't' directory in my autoconf based project and put the libtab header and sources there. Tests look pretty much the same as in Perl:
# t/simple_tests.c #include <stdio.h> #include "tap.h" #include "something.h" int main(void) { plan_tests(1); /* * A simple example of a test. */ ok(1 + 1 == 2, "Basic arithmetic works"); return exit_status(); /* Return the correct exit code */ }
A simple t/Makefile.am could look like this:
# binaries check_PROGRAMS = simple_tests simple_tests_SOURCES = simple_tests.c tap.c ../src/something.c\ tap.h ../src/something.h simple_tests_CFLAGS = -Wall --pedantic -std=c99 -I ../src TESTS = simple_tests
Then add 't' in your main Makefile.am:
SUBDIRS = src t
Then you can run the tests with 'make check'.

In reply to Re^2: Unit testing of C source code by lima1
in thread Unit testing of C source code by Satish@Stag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found