test.cpp

来自「This is the second part of that lab manu」· C++ 代码 · 共 41 行

CPP
41
字号
//: TestSuite:Test.cpp {O}
// From "Thinking in C++, 2nd Edition, Volume 2"
// by Bruce Eckel & Chuck Allison, (c) 2001 MindView, Inc.
// Available at www.BruceEckel.com.
#include "Test.h"
#include <iostream>
#include <typeinfo> // Visual C++ requires /GR""
using namespace std;

void Test::do_test(bool cond, 
                   const std::string& lbl,
                   const char* fname, 
                   long lineno){
  if (!cond)
    do_fail(lbl, fname, lineno);
  else
    succeed_();
}

void Test::do_fail(const std::string& lbl,
                   const char* fname, 
                   long lineno){
  ++nFail;
  if (osptr){
    *osptr << typeid(*this).name()
             << "failure: (" << lbl << ") , "
             << fname
             << " (line " << lineno << ")\n";
  }
}

long Test::report() const {
  if (osptr){
    *osptr << "Test \"" << typeid(*this).name()
             << "\":\n\tPassed: " << nPass
             << "\tFailed: " << nFail
             << endl;
  }
  return nFail;
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?