Skip to content

Commit bcde677

Browse files
committed
r10 | charles.nicholson | 2010-03-17 18:04:53 -0500 (Wed, 17 Mar 2010) | 1 line
rename unittestpp folder to src, fix bin/lib/obj folders in vcproj files
1 parent c8f551a commit bcde677

File tree

8 files changed

+862
-288
lines changed

8 files changed

+862
-288
lines changed

src/MemoryOutStream.h

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
#ifndef UNITTEST_MEMORYOUTSTREAM_H
2-
#define UNITTEST_MEMORYOUTSTREAM_H
3-
4-
#include "Config.h"
5-
6-
#ifndef UNITTEST_USE_CUSTOM_STREAMS
7-
8-
#include <sstream>
9-
10-
namespace UnitTest
11-
{
12-
13-
class MemoryOutStream : public std::ostringstream
14-
{
15-
public:
16-
MemoryOutStream() {}
17-
~MemoryOutStream() {}
18-
char const* GetText() const;
19-
20-
private:
21-
MemoryOutStream(MemoryOutStream const&);
22-
void operator =(MemoryOutStream const&);
23-
24-
mutable std::string m_text;
25-
};
26-
27-
}
28-
29-
#else
30-
31-
#include <cstddef>
32-
33-
namespace UnitTest
34-
{
35-
36-
class MemoryOutStream
37-
{
38-
public:
39-
explicit MemoryOutStream(int const size = 256);
40-
~MemoryOutStream();
41-
42-
char const* GetText() const;
43-
44-
MemoryOutStream& operator << (char const* txt);
45-
MemoryOutStream& operator << (int n);
46-
MemoryOutStream& operator << (long n);
47-
MemoryOutStream& operator << (unsigned long n);
48-
MemoryOutStream& operator << (float f);
49-
MemoryOutStream& operator << (double d);
50-
MemoryOutStream& operator << (void const* p);
51-
MemoryOutStream& operator << (unsigned int s);
52-
53-
enum { GROW_CHUNK_SIZE = 32 };
54-
int GetCapacity() const;
55-
56-
private:
57-
void operator= (MemoryOutStream const&);
58-
void GrowBuffer(int capacity);
59-
60-
int m_capacity;
61-
char* m_buffer;
62-
};
63-
64-
}
65-
66-
#endif
67-
68-
#endif
1+
#ifndef UNITTEST_MEMORYOUTSTREAM_H
2+
#define UNITTEST_MEMORYOUTSTREAM_H
3+
4+
#include "Config.h"
5+
6+
#ifndef UNITTEST_USE_CUSTOM_STREAMS
7+
8+
#include <sstream>
9+
10+
namespace UnitTest
11+
{
12+
13+
class MemoryOutStream : public std::ostringstream
14+
{
15+
public:
16+
MemoryOutStream() {}
17+
~MemoryOutStream() {}
18+
char const* GetText() const;
19+
20+
private:
21+
MemoryOutStream(MemoryOutStream const&);
22+
void operator =(MemoryOutStream const&);
23+
24+
mutable std::string m_text;
25+
};
26+
27+
}
28+
29+
#else
30+
31+
#include <cstddef>
32+
33+
namespace UnitTest
34+
{
35+
36+
class MemoryOutStream
37+
{
38+
public:
39+
explicit MemoryOutStream(int const size = 256);
40+
~MemoryOutStream();
41+
42+
char const* GetText() const;
43+
44+
MemoryOutStream& operator << (char const* txt);
45+
MemoryOutStream& operator << (int n);
46+
MemoryOutStream& operator << (long n);
47+
MemoryOutStream& operator << (unsigned long n);
48+
MemoryOutStream& operator << (float f);
49+
MemoryOutStream& operator << (double d);
50+
MemoryOutStream& operator << (void const* p);
51+
MemoryOutStream& operator << (unsigned int s);
52+
53+
enum { GROW_CHUNK_SIZE = 32 };
54+
int GetCapacity() const;
55+
56+
private:
57+
void operator= (MemoryOutStream const&);
58+
void GrowBuffer(int capacity);
59+
60+
int m_capacity;
61+
char* m_buffer;
62+
};
63+
64+
}
65+
66+
#endif
67+
68+
#endif

src/Posix/TimeHelpers.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
#include "TimeHelpers.h"
2-
#include <unistd.h>
3-
4-
namespace UnitTest {
5-
6-
Timer::Timer()
7-
{
8-
m_startTime.tv_sec = 0;
9-
m_startTime.tv_usec = 0;
10-
}
11-
12-
void Timer::Start()
13-
{
14-
gettimeofday(&m_startTime, 0);
15-
}
16-
17-
double Timer::GetTimeInMs() const
18-
{
19-
struct timeval currentTime;
20-
gettimeofday(&currentTime, 0);
21-
22-
double const dsecs = currentTime.tv_sec - m_startTime.tv_sec;
23-
double const dus = currentTime.tv_usec - m_startTime.tv_usec;
24-
25-
return (dsecs * 1000.0) + (dus / 1000.0);
26-
}
27-
28-
void TimeHelpers::SleepMs(int ms)
29-
{
30-
usleep(ms * 1000);
31-
}
32-
33-
}
1+
#include "TimeHelpers.h"
2+
#include <unistd.h>
3+
4+
namespace UnitTest {
5+
6+
Timer::Timer()
7+
{
8+
m_startTime.tv_sec = 0;
9+
m_startTime.tv_usec = 0;
10+
}
11+
12+
void Timer::Start()
13+
{
14+
gettimeofday(&m_startTime, 0);
15+
}
16+
17+
double Timer::GetTimeInMs() const
18+
{
19+
struct timeval currentTime;
20+
gettimeofday(&currentTime, 0);
21+
22+
double const dsecs = currentTime.tv_sec - m_startTime.tv_sec;
23+
double const dus = currentTime.tv_usec - m_startTime.tv_usec;
24+
25+
return (dsecs * 1000.0) + (dus / 1000.0);
26+
}
27+
28+
void TimeHelpers::SleepMs(int ms)
29+
{
30+
usleep(ms * 1000);
31+
}
32+
33+
}

src/Posix/TimeHelpers.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#ifndef UNITTEST_TIMEHELPERS_H
2-
#define UNITTEST_TIMEHELPERS_H
3-
4-
#include <sys/time.h>
5-
6-
namespace UnitTest {
7-
8-
class Timer
9-
{
10-
public:
11-
Timer();
12-
void Start();
13-
double GetTimeInMs() const;
14-
15-
private:
16-
struct timeval m_startTime;
17-
};
18-
19-
20-
namespace TimeHelpers
21-
{
22-
void SleepMs (int ms);
23-
}
24-
25-
26-
}
27-
28-
#endif
1+
#ifndef UNITTEST_TIMEHELPERS_H
2+
#define UNITTEST_TIMEHELPERS_H
3+
4+
#include <sys/time.h>
5+
6+
namespace UnitTest {
7+
8+
class Timer
9+
{
10+
public:
11+
Timer();
12+
void Start();
13+
double GetTimeInMs() const;
14+
15+
private:
16+
struct timeval m_startTime;
17+
};
18+
19+
20+
namespace TimeHelpers
21+
{
22+
void SleepMs (int ms);
23+
}
24+
25+
26+
}
27+
28+
#endif

src/TestReporterStdout.cpp

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
#include "TestReporterStdout.h"
2-
#include <cstdio>
3-
4-
#include "TestDetails.h"
5-
6-
// cstdio doesn't pull in namespace std on VC6, so we do it here.
7-
#if defined(_MSC_VER) && (_MSC_VER == 1200)
8-
namespace std {}
9-
#endif
10-
11-
namespace UnitTest {
12-
13-
void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure)
14-
{
15-
#if defined(__APPLE__) || defined(__GNUG__)
16-
char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n";
17-
#else
18-
char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
19-
#endif
20-
21-
using namespace std;
22-
printf(errorFormat, details.filename, details.lineNumber, details.testName, failure);
23-
}
24-
25-
void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)
26-
{
27-
}
28-
29-
void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float)
30-
{
31-
}
32-
33-
void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount,
34-
int const failureCount, float secondsElapsed)
35-
{
36-
using namespace std;
37-
38-
if (failureCount > 0)
39-
printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount);
40-
else
41-
printf("Success: %d tests passed.\n", totalTestCount);
42-
43-
printf("Test time: %.2f seconds.\n", secondsElapsed);
44-
}
45-
46-
}
1+
#include "TestReporterStdout.h"
2+
#include <cstdio>
3+
4+
#include "TestDetails.h"
5+
6+
// cstdio doesn't pull in namespace std on VC6, so we do it here.
7+
#if defined(_MSC_VER) && (_MSC_VER == 1200)
8+
namespace std {}
9+
#endif
10+
11+
namespace UnitTest {
12+
13+
void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure)
14+
{
15+
#if defined(__APPLE__) || defined(__GNUG__)
16+
char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n";
17+
#else
18+
char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
19+
#endif
20+
21+
using namespace std;
22+
printf(errorFormat, details.filename, details.lineNumber, details.testName, failure);
23+
}
24+
25+
void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)
26+
{
27+
}
28+
29+
void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float)
30+
{
31+
}
32+
33+
void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount,
34+
int const failureCount, float secondsElapsed)
35+
{
36+
using namespace std;
37+
38+
if (failureCount > 0)
39+
printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount);
40+
else
41+
printf("Success: %d tests passed.\n", totalTestCount);
42+
43+
printf("Test time: %.2f seconds.\n", secondsElapsed);
44+
}
45+
46+
}

0 commit comments

Comments
 (0)