My Project  debian-1:4.1.1-p2+ds-4build1
Descriptions.cpp
Go to the documentation of this file.
1 #ifndef __cxxtest__Descriptions_cpp__
2 #define __cxxtest__Descriptions_cpp__
3 
4 #include <cxxtest/Descriptions.h>
5 
6 namespace CxxTest
7 {
11 
12  //
13  // Convert total tests to string
14  //
15 #ifndef _CXXTEST_FACTOR
16  char *WorldDescription::strTotalTests( char *s ) const
17  {
18  numberToString( numTotalTests(), s );
19  return s;
20  }
21 #else // _CXXTEST_FACTOR
22  char *WorldDescription::strTotalTests( char *s ) const
23  {
24  char *p = numberToString( numTotalTests(), s );
25 
26  if ( numTotalTests() <= 1 )
27  return s;
28 
29  unsigned n = numTotalTests();
30  unsigned numFactors = 0;
31 
32  for ( unsigned factor = 2; (factor * factor) <= n; factor += (factor == 2) ? 1 : 2 ) {
33  unsigned power;
34 
35  for ( power = 0; (n % factor) == 0; n /= factor )
36  ++ power;
37 
38  if ( !power )
39  continue;
40 
41  p = numberToString( factor, copyString( p, (numFactors == 0) ? " = " : " * " ) );
42  if ( power > 1 )
43  p = numberToString( power, copyString( p, "^" ) );
44  ++ numFactors;
45  }
46 
47  if ( n > 1 ) {
48  if ( !numFactors )
49  copyString( p, tracker().failedTests() ? " :(" : tracker().warnings() ? " :|" : " :)" );
50  else
51  numberToString( n, copyString( p, " * " ) );
52  }
53  return s;
54  }
55 #endif // _CXXTEST_FACTOR
56 };
57 
58 #endif // __cxxtest__Descriptions_cpp__
CxxTest::copyString
char * copyString(char *dst, const char *src)
Definition: ValueTraits.cpp:30
Descriptions.h
CxxTest::WorldDescription::~WorldDescription
virtual ~WorldDescription()
Definition: Descriptions.cpp:10
CxxTest::SuiteDescription::~SuiteDescription
virtual ~SuiteDescription()
Definition: Descriptions.cpp:9
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: canonicalform.cc:1837
CxxTest::s
char * s
Definition: ValueTraits.h:143
CxxTest::WorldDescription::strTotalTests
char * strTotalTests(char *) const
Definition: Descriptions.cpp:16
CxxTest::WorldDescription::numTotalTests
virtual unsigned numTotalTests(void) const =0
factor
CanonicalForm factor
Definition: facAbsFact.cc:101
p
int p
Definition: cfModGcd.cc:4019
CxxTest
Definition: Descriptions.cpp:6
CxxTest::TestDescription::~TestDescription
virtual ~TestDescription()
Definition: Descriptions.cpp:8
CxxTest::tracker
TestTracker & tracker()
Definition: TestTracker.h:111