~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/examples/ClockerPlugIn/ClockerModel.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// //////////////////////////////////////////////////////////////////////////
 
2
// Header file ClockerModel.h for class ClockerModel
 
3
// (c)Copyright 2000, Baptiste Lepilleur.
 
4
// Created: 2002/06/14
 
5
// //////////////////////////////////////////////////////////////////////////
 
6
#ifndef CLOCKERMODEL_H
 
7
#define CLOCKERMODEL_H
 
8
 
 
9
#include <cppunit/TestPath.h>
 
10
#include <cppunit/portability/CppUnitVector.h>
 
11
#include <cppunit/portability/CppUnitMap.h>
 
12
#include <cppunit/portability/CppUnitStack.h>
 
13
#include <string>
 
14
 
 
15
#ifdef CLOCKER_USE_WINNTTIMER
 
16
#include "WinNtTimer.h"
 
17
typedef WinNtTimer Timer;
 
18
#else
 
19
#include "Timer.h"
 
20
#endif
 
21
 
 
22
 
 
23
/// Model that represents test timing.
 
24
class ClockerModel
 
25
{
 
26
public:
 
27
  /*! Constructs a ClockerModel object.
 
28
   */
 
29
  ClockerModel();
 
30
 
 
31
  /// Destructor.
 
32
  virtual ~ClockerModel();
 
33
 
 
34
  void setExpectedTestCount( int count );
 
35
 
 
36
  void enterTest( CPPUNIT_NS::Test *test,
 
37
                  bool isSuite );
 
38
 
 
39
  void exitTest( CPPUNIT_NS::Test *test,
 
40
                 bool isSuite );
 
41
 
 
42
  double totalElapsedTime() const;
 
43
 
 
44
  double averageTestCaseTime() const;
 
45
 
 
46
  double testTimeFor( CPPUNIT_NS::Test *test ) const;
 
47
 
 
48
  double testTimeFor( int testIndex ) const;
 
49
 
 
50
  static std::string timeStringFor( double time );
 
51
 
 
52
  bool isSuite( int testIndex ) const;
 
53
 
 
54
  const CPPUNIT_NS::TestPath &testPathFor( int testIndex ) const;
 
55
 
 
56
  // -1 is none
 
57
  int indexOf( CPPUNIT_NS::Test *test ) const;
 
58
 
 
59
  int childCountFor( int testIndex ) const;
 
60
 
 
61
  int childAtFor( int testIndex, 
 
62
                  int chidIndex ) const;
 
63
 
 
64
private:
 
65
  struct TestInfo
 
66
  {
 
67
    CPPUNIT_NS::TestPath m_path;
 
68
    Timer m_timer;
 
69
    bool m_isSuite;
 
70
    CppUnitVector<int> m_childIndexes;
 
71
  };
 
72
 
 
73
  /// Prevents the use of the copy constructor.
 
74
  ClockerModel( const ClockerModel &other );
 
75
 
 
76
  /// Prevents the use of the copy operator.
 
77
  void operator =( const ClockerModel &other );
 
78
 
 
79
private:
 
80
  CPPUNIT_NS::TestPath m_currentPath;
 
81
  
 
82
  int m_testCaseCount;
 
83
  double m_totalTestCaseTime;
 
84
 
 
85
  typedef CppUnitMap<CPPUNIT_NS::Test *, int> TestToIndexes;
 
86
  
 
87
  TestToIndexes m_testToIndexes;
 
88
  CppUnitStack<int> m_testIndexes;
 
89
  CppUnitVector<TestInfo> m_tests;
 
90
};
 
91
 
 
92
 
 
93
 
 
94
 
 
95
#endif  // CLOCKERMODEL_H