Code

Initialize pointer.
[inkscape.git] / cxxtest / cxxtest / Descriptions.cpp
1 #ifndef __cxxtest__Descriptions_cpp__
2 #define __cxxtest__Descriptions_cpp__
4 #include <cxxtest/Descriptions.h>
6 namespace CxxTest
7 {
8     TestDescription::~TestDescription() {}
9     SuiteDescription::~SuiteDescription() {}
10     WorldDescription::~WorldDescription() {}
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 );
26         if ( numTotalTests() <= 1 )
27             return s;
29         unsigned n = numTotalTests();
30         unsigned numFactors = 0;
32         for ( unsigned factor = 2; (factor * factor) <= n; factor += (factor == 2) ? 1 : 2 ) {
33             unsigned power;
35             for ( power = 0; (n % factor) == 0; n /= factor )
36                 ++ power;
38             if ( !power )
39                 continue;
41             p = numberToString( factor, copyString( p, (numFactors == 0) ? " = " : " * " ) );
42             if ( power > 1 )
43                 p = numberToString( power, copyString( p, "^" ) );
44             ++ numFactors;
45         }
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 };
58 #endif // __cxxtest__Descriptions_cpp__