O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing the Classes with Known Cases

Tests fall into several categories as well:

  • Empty tests determine whether a class, program, or system works correctly the first time it is run, or when it has no data. For instance, testing the most recent implementation of the calculator with an empty tape file shows that you need the following in aPersistentTapeExternalInterface:

     1:          char OperatorChar;
     2:          myTapeSourceInputStream >> OperatorChar;
     3:
    *4:          if (OperatorChar == '\0')
     5:          {
     6:             myTapeSourceInputStream.close();
     7:             return anExternalInterface:: GetOperatorChar();
     8:          }
     9:          else
    10:          {
    11:             return OperatorChar;
    12:          };
    

    An empty test reveals the need for Line 4; the empty file returns a char '\0', and when this character passes into the system it causes a bad ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required