Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CppUnit testing

CppUnit testing

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasetestingbeta-testingquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gregarion
    wrote on last edited by
    #1

    Hey guys, i am trying to test one of my classes using cppunit. the class is suppose to extract data out of a certain text file and then displays it... Code:

    void readNasdaq::Nasdaq(fstream& myfile)
    {
    string templine ;
    string line;

    while (getline (myfile,templine) )
    {
        line.append(templine);
    }
    
    int NasdaqValueID = line.find ("id=\\"yfs\_l10\_^ixic\\">" , 0) ;
    int NasdaqValueCount = line.find ("</span></td><td class=\\"ticker\_down\\"><span class=\\"streaming-datum\\" id=\\"yfs\_c10\_^ixic\\">" , 0) ;
    
    int LocationNasdaqValue = NasdaqValueID + 19 ;
    int LengthOfNasdaqValue = NasdaqValueCount - LocationNasdaqValue ;
    

    string NasdaqValue = line.substr( LocationNasdaqValue , LengthOfNasdaqValue ) ;

    cout << " " << endl ;
    cout << "The Value Index of Nasdaq is " << NasdaqValue << endl ;

    int NasdaqValueChangeID = line.find ("id=\"yfs_c10_^ixic\">" , 0 ) ;
    int NasdaqValueChangeCount = line.find ("</span></td><td class=\"right_cell ticker_down\"><span class=\"streaming-datum\" id=\"yfs_pp0_^ixic\">" , 0) ;

    int LocationNasdaqValueChange = NasdaqValueChangeID + 19 ;
    int LengthOfNasdaqValueChange = NasdaqValueChangeCount - LocationNasdaqValueChange ;

    string NasdaqValueChange = line.substr (LocationNasdaqValueChange , LengthOfNasdaqValueChange ) ;

    cout << "The Value Change for Nasdaq is " << NasdaqValueChange << endl ;

    the problem i have with my cppunit is how am i suppose to read the value being outputted and test it... Code:

    #include "financetest.h"
    #include "finance.h"

    CPPUNIT_TEST_SUITE_REGISTRATION (FinanceTest);

    void FinanceTest::setUp()
    {
    New = " ";
    NewValue = " " ;

    }

    void FinanceTest::tearDown()
    {

    }

    void FinanceTest::testEquals()
    {

    }
    

    How can i continue from here.. really need some help from this

    D 1 Reply Last reply
    0
    • G gregarion

      Hey guys, i am trying to test one of my classes using cppunit. the class is suppose to extract data out of a certain text file and then displays it... Code:

      void readNasdaq::Nasdaq(fstream& myfile)
      {
      string templine ;
      string line;

      while (getline (myfile,templine) )
      {
          line.append(templine);
      }
      
      int NasdaqValueID = line.find ("id=\\"yfs\_l10\_^ixic\\">" , 0) ;
      int NasdaqValueCount = line.find ("</span></td><td class=\\"ticker\_down\\"><span class=\\"streaming-datum\\" id=\\"yfs\_c10\_^ixic\\">" , 0) ;
      
      int LocationNasdaqValue = NasdaqValueID + 19 ;
      int LengthOfNasdaqValue = NasdaqValueCount - LocationNasdaqValue ;
      

      string NasdaqValue = line.substr( LocationNasdaqValue , LengthOfNasdaqValue ) ;

      cout << " " << endl ;
      cout << "The Value Index of Nasdaq is " << NasdaqValue << endl ;

      int NasdaqValueChangeID = line.find ("id=\"yfs_c10_^ixic\">" , 0 ) ;
      int NasdaqValueChangeCount = line.find ("</span></td><td class=\"right_cell ticker_down\"><span class=\"streaming-datum\" id=\"yfs_pp0_^ixic\">" , 0) ;

      int LocationNasdaqValueChange = NasdaqValueChangeID + 19 ;
      int LengthOfNasdaqValueChange = NasdaqValueChangeCount - LocationNasdaqValueChange ;

      string NasdaqValueChange = line.substr (LocationNasdaqValueChange , LengthOfNasdaqValueChange ) ;

      cout << "The Value Change for Nasdaq is " << NasdaqValueChange << endl ;

      the problem i have with my cppunit is how am i suppose to read the value being outputted and test it... Code:

      #include "financetest.h"
      #include "finance.h"

      CPPUNIT_TEST_SUITE_REGISTRATION (FinanceTest);

      void FinanceTest::setUp()
      {
      New = " ";
      NewValue = " " ;

      }

      void FinanceTest::tearDown()
      {

      }

      void FinanceTest::testEquals()
      {

      }
      

      How can i continue from here.. really need some help from this

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      I know it's early, but I'm not seeing what readNasdaq::Nasdaq() has to do with your question. As I understand it, CppUnit is a framework for creating unit tests in C++. What does this have to do with extracting data out of a text file and displaying it?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Man who follows car will be exhausted." - Confucius

      G 1 Reply Last reply
      0
      • D David Crow

        I know it's early, but I'm not seeing what readNasdaq::Nasdaq() has to do with your question. As I understand it, CppUnit is a framework for creating unit tests in C++. What does this have to do with extracting data out of a text file and displaying it?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        G Offline
        G Offline
        gregarion
        wrote on last edited by
        #3

        Sorry, what i meant was to show my class and how it get the information i want to be displayed. I got to use cppunit to test this class to show that it is extracting the right information. For example, if the class extracts "a" , i will have to compare it to the cppunit test and see if it has the same value also. The problem i am facing is how do i do a test based on the output.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups