VTest.cxx
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:3k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

C/C++

  1. /* ====================================================================
  2.  * The Vovida Software License, Version 1.0 
  3.  * 
  4.  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
  5.  * 
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  * 
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in
  15.  *    the documentation and/or other materials provided with the
  16.  *    distribution.
  17.  * 
  18.  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
  19.  *    and "Vovida Open Communication Application Library (VOCAL)" must
  20.  *    not be used to endorse or promote products derived from this
  21.  *    software without prior written permission. For written
  22.  *    permission, please contact vocal@vovida.org.
  23.  *
  24.  * 4. Products derived from this software may not be called "VOCAL", nor
  25.  *    may "VOCAL" appear in their name, without prior written
  26.  *    permission of Vovida Networks, Inc.
  27.  * 
  28.  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
  29.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
  31.  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
  32.  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
  33.  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
  34.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  35.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  36.  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  37.  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  39.  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  40.  * DAMAGE.
  41.  * 
  42.  * ====================================================================
  43.  * 
  44.  * This software consists of voluntary contributions made by Vovida
  45.  * Networks, Inc. and many individuals on behalf of Vovida Networks,
  46.  * Inc.  For more information on Vovida Networks, Inc., please see
  47.  * <http://www.vovida.org/>.
  48.  *
  49.  */
  50. static const char* const VTest_cxx_Version =
  51.     "$Id: VTest.cxx,v 1.6 2001/06/27 01:43:45 bko Exp $";
  52. #include "VTest.hxx"
  53. #include <iostream>
  54. #ifdef WIN32
  55. using std::string;
  56. using std::cout;
  57. using std::endl;
  58. #endif
  59. VTest::VTest(const char* testName)
  60.         : myName(testName),
  61.         allPassed(true)
  62. {
  63.     // check for and replace a trailing .cxx
  64.     string::size_type suffix = myName.find_last_of(".cxx");
  65.     if (suffix == myName.length() - 1)
  66.     {
  67.         // replace
  68.         myName.replace(suffix - 3, 4, "");
  69.     }
  70. }
  71. void VTest::test(int testNumber, bool testPassed, const char* comment = 0)
  72. {
  73.     if (testPassed)
  74.     {
  75.         cout << "PASSED: ";
  76.     }
  77.     else
  78.     {
  79.         cout << "FAILED: ";
  80.         allPassed = false;
  81.     }
  82.     cout << myName << ":";
  83.     cout << testNumber << ": ";
  84.     if (comment)
  85.     {
  86.         cout << comment;
  87.     }
  88.     cout << endl;
  89. }
  90. int VTest::exitCode()
  91. {
  92.     if (allPassed)
  93.     {
  94.         return 0;
  95.     }
  96.     else
  97.     {
  98.         return 1;
  99.     }
  100. }