CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Question Cpp unit testing of classes

    I am an intern in Hp Global software pvt ltd.My job out here is to test native cpp modules.I have encountered a serious problem.my code doesnt have any error but when i debug it,it breaks with a message
    [Windows has triggered a breakpoint in STAR_RemoteDeployer.exe.
    This may be due to a corruption of the heap, which indicates a bug in STAR_RemoteDeployer.exe or any of the DLLs it has loaded.
    This may also be due to the user pressing F12 while STAR_RemoteDeployer.exe has focus.
    The output window may have more diagnostic information.]
    And i am directed to free.c page and the error shown is-
    retval = HeapFree(_crtheap, 0, pBlock);
    (error over here)-> if (retval == 0)
    {
    errno = _get_errno_from_oserr(GetLastError());
    }
    this is my main program
    int main (int argc, char* argv[])
    {
    // informs test-listener about testresults
    CPPUNIT_NS :: TestResult testresult;

    // register listener for collecting the test-results
    CPPUNIT_NS :: TestResultCollector collectedresults;
    testresult.addListener (&collectedresults);

    // register listener for per-test progress output
    CPPUNIT_NS :: BriefTestProgressListener progress;
    testresult.addListener (&progress);

    // insert test-suite at test-runner by registry
    CPPUNIT_NS :: TestRunner testrunner;
    testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry::getRegistry().makeTest ());
    testrunner.run (testresult);(this is the place where it is getting stuck everytime)

    // output results in compiler-format
    CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
    compileroutputter.write ();

    // return 0 if tests were successful
    return collectedresults.wasSuccessful () ? 0 : 1;
    }
    please help.i have to give a presentation soon in my office.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Cpp unit testing of classes

    Well I'm sorry to tell you that your code or the code you're testing have bugs. Most likely you have either a buffer overrun bug or a double delete bug.

    Run it in the debugger and when it breaks check the callstack and variables for clues.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Apr 2011
    Posts
    3

    Re: Cpp unit testing of classes

    the main program worked fine when i used in a project of my own.when i decided to add the test cases in the same project that i was supposed to test,the problem arised(thats what i was asked to do by my team mentor).
    The parent project is working fine individually and the cppunit testing is working fine when used individually,but when they are merged problem arises.
    It worked on the same station,OS and there had been no updates,rollbacks or system restores.

    the o/p to "errno" is not helping too

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Cpp unit testing of classes

    There's a hidden bug in the code somewhere. Adding the testcases changed how the code is laid out in memory, revealing the bug. Did you run it in a debugger?

    Viggy

  5. #5
    Join Date
    Apr 2011
    Posts
    3

    Re: Cpp unit testing of classes

    I have run in a debugger.i will again go thru it.which code are u talking abt the parent code or the main function of the test casses

  6. #6
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Cpp unit testing of classes

    Could be either one...

    Viggy

  7. #7
    Join Date
    Apr 2011
    Posts
    3

    Question Re: Cpp unit testing of classes

    while running in the debugging executable its running fine but while debugging in the debugging executable its breaking.
    Any help?

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Cpp unit testing of classes

    When "its breaking" have a look at the Call stack and find the last line of your own code executed before (or while) breaking.
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured