Skip to content

Commit 59fcbc4

Browse files
committed
Tests are now for C++98 and onwards
1 parent fe5bb2d commit 59fcbc4

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

test/src/sleep.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace tests
66
{
7+
#if __cplusplus >= 201102L
78
int sleep()
89
{
910
timeUtils::Sleep sleep("main");
@@ -30,5 +31,10 @@ namespace tests
3031

3132
return 0;
3233
}
34+
35+
#else
36+
int sleep() { return -1; }
37+
38+
#endif
3339
}
3440

test/src/stopwatch.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#include <chrono>
2-
#include <thread>
3-
41
#include <iostream>
52

63
#include "../../inc/Stopwatch.hpp"
74

5+
#if __cplusplus >= 201102L
6+
#include <chrono>
7+
#include <thread>
8+
89
namespace tests
910
{
1011
int stopwatch()
@@ -49,3 +50,9 @@ namespace tests
4950
}
5051
}
5152

53+
#else
54+
namespace tests
55+
{ int stopwatch() { return -1; } }
56+
57+
#endif
58+

test/src/time.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <iostream>
22
#include <unistd.h>
3-
#include <chrono>
4-
#include <thread>
3+
#include <cstdlib>
54

65
#include "../../inc/Time.hpp"
76

7+
#if __cplusplus >= 199711L
88
namespace tests
99
{
1010
int time()
@@ -15,24 +15,27 @@ namespace tests
1515
timeUtils::DateInfo dateInfo;
1616
timeUtils::TimeInfo timeInfo;
1717

18-
time.setUTCOffset(5, 30);
18+
time.setUTCOffset(11, 59);
19+
time.addOffset(1, 1);
20+
21+
timeInfo.is12hFormat = time.set12hFormat(true);
1922

2023
while (1)
2124
{
2225
time.update(tzInfo);
2326
time.update(dateInfo);
2427
time.update(timeInfo);
2528

26-
timeInfo.is12hFormat = time.set12hFormat(true);
27-
2829
std::cout
2930
<< "- TIME ZONE INFO -\n"
3031
<< "GMT Off? : " << tzInfo.gmtOff << "\n"
3132
<< "Is DST? : " << tzInfo.isDST << "\n"
3233
<< "Current timezone : " << tzInfo.timezone << "\n"
3334
<< "Current UTC timezone : UTC " <<
34-
(std::stoi(tzInfo.utcTimezone[0]) >= 0 ? "+" : "") + tzInfo.utcTimezone[0] << ":" <<
35+
(tzInfo.utcTimezone[0]) << ":" <<
3536
tzInfo.utcTimezone[1] << "\n"
37+
<< "UTC Offset: " << time.getUTCOffset().hour << " : " <<time.getUTCOffset().min << "\n"
38+
<< "Add Offset: " << time.getAddOffset().hour << " : " <<time.getAddOffset().min << "\n"
3639

3740
<< "- TIME INFO -\n"
3841
<< "Hour: " << timeInfo.hour << "\n"
@@ -51,11 +54,15 @@ namespace tests
5154

5255
<< "\r" << std::flush;
5356

54-
std::this_thread::sleep_for(std::chrono::milliseconds(50));
55-
56-
system("clear");
57+
system("clear");
5758
}
5859

5960
return 0;
6061
}
6162
}
63+
64+
#else
65+
namespace tests
66+
{ int time() { return -1; } }
67+
68+
#endif

test/src/timer.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include <iostream>
2-
#include <chrono>
3-
#include <thread>
42

53
#include "../../inc/Timer.hpp"
64

5+
#if __cplusplus >= 201102L
6+
#include <chrono>
7+
#include <thread>
8+
79
namespace tests
810
{
911
int timer()
@@ -45,3 +47,9 @@ namespace tests
4547
return 0;
4648
}
4749
}
50+
51+
#else
52+
namespace tests
53+
{ int timer() { return -1; } }
54+
55+
#endif

0 commit comments

Comments
 (0)