Thread: Test cases

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    2

    Test cases

    Hello I had a question about test cases. I currently have a main program that stores data in a BST tree and when I call a void print function that I have in a separate file it prints the correct results.

    However what I want to do is compare these results that I have printed to the results in a separate file that I have created that contains the correct results. How would I approach this without any < diff commands on the linux shell.

    I need to strictly have this comparison in my program code so that if any user decides to use my main program to test his program, he can just run my main program and it will say if the output is correct (automatically).

    Thanks, Ronald
    Last edited by desertstorm; 05-12-2006 at 04:59 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Read the first line of the file, compare it with the first value you would have printed.
    Read the second line of the file, compare it with the second value you would have printed...
    Repeat until you run out of file or values, or both, or something doesn't match.
    Return or display the appropriate message.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Run diff from within your program perhaps?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sustring test puzzle
    By WDT in forum C# Programming
    Replies: 3
    Last Post: 06-29-2009, 07:19 AM
  2. Help needed to verify a new on-line C test
    By JanHruska in forum Projects and Job Recruitment
    Replies: 15
    Last Post: 06-20-2009, 06:48 AM
  3. Question About Linker Errors In Dev-C++
    By ShadowMetis in forum C++ Programming
    Replies: 9
    Last Post: 08-18-2004, 08:42 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. I need to use 0 to quit a program
    By cwest in forum C Programming
    Replies: 2
    Last Post: 12-15-2001, 08:37 AM