Thread: Testing of C code

  1. #1
    Registered User
    Join Date
    Feb 2012

    Testing of C code

    Can someone please help me with. Suppose i have developed a big logic as a separate function. Is it possible for me to test the function alone independent of main routine using some testing tool. I plan to give all the possible inputs and verify my expected output with actual values. I am asking this since i find lot of bugs while doing actual tests and i have to keep flashing several times.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Yes, you can use an existing unit test library/framework to help you, or write your own test code to automate the testing.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2009
    Look for the keywords "unit testing".

    NOTE: Your post implies you are doing embedded development; I am NOT sure if unit testing is much harder or not when doing that.
    But, I do know that writing portable C code should make it easier.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. software testing for c code in linux
    By amnakhan786 in forum C Programming
    Replies: 2
    Last Post: 11-10-2011, 11:34 AM
  2. c code for software testing-linux
    By amnakhan786 in forum Linux Programming
    Replies: 1
    Last Post: 11-10-2011, 01:49 AM
  3. set testing code
    By zxcv in forum C++ Programming
    Replies: 8
    Last Post: 12-22-2008, 02:58 AM
  4. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM

Tags for this Thread