aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanJacobs2022-07-12 23:05:27 +0200
committerSanJacobs2022-07-12 23:05:27 +0200
commit0163ec13c0e4efe890f8c79a838a26acffa0088e (patch)
treefcb82c9efb06e43244a185447b2aaca05acc357c
parent8b3c5ad51bc9c9336c11d1fc339532e078a3ad47 (diff)
downloadsatscalc-0163ec13c0e4efe890f8c79a838a26acffa0088e.tar.gz
satscalc-0163ec13c0e4efe890f8c79a838a26acffa0088e.tar.bz2
satscalc-0163ec13c0e4efe890f8c79a838a26acffa0088e.zip
New, cleaner testing structure
-rwxr-xr-xsrc/main.cpp80
-rw-r--r--src/test.cpp83
-rw-r--r--src/test.h6
-rwxr-xr-xtest.sh12
4 files changed, 103 insertions, 78 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 99e5647..2af0702 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,89 +22,13 @@ along with this program. If not, see https://www.gnu.org/licenses/
#include <iostream>
#include "time.h"
+#include "test.h"
int main(int argc, char* argv[])
{
if(argc > 1){
if(std::string(argv[1])=="test") {
- moment calltime{30, 8, 27, 11, 2010};
- moment wraptime{30, 16, 27, 11, 2010};
- timeblock workday{calltime, wraptime};
-
- std::cout << "\n\n --- TIME UNITS TEST ---\n\n";
- std::cout << "Calltime: " << timeprint(calltime) << std::endl;
- std::cout << "Wraptime: " << timeprint(wraptime) << std::endl;
-
- std::cout << "\nWorkday:\n";
- std::cout << timeprint(workday) << std::endl;
-
-
-
- std::cout << "\n\n --- TIME MATH TEST ---\n\n";
-
- std::cout << "Difference between calltime and wraptime:\n";
- std::cout << (calltime-wraptime) << std::endl;
- std::cout << "Other way around, should show same result:\n";
- std::cout << (calltime-wraptime) << std::endl;
- std::cout << "As method on workday:\n";
- std::cout << (workday.hourcount()) << std::endl;
-
- std::cout << "\nSplitting workday into workday and second_half...\n";
- moment splitpoint{0, 12, 27, 11, 2010};
- timeblock first_half{timesplit(workday, splitpoint)};
-
- std::cout << "\nSplitpoint: " << timeprint(splitpoint) << std::endl;
- std::cout << "\nfirst_half:\n";
- std::cout << timeprint(first_half) << std::endl;
- std::cout << "\nWorkday:\n";
- std::cout << timeprint(workday) << std::endl;
-
- std::cout << "\nSplitting second_half at erronious point...\n";
- moment erronious_splitpoint{0, 14, 27, 11, 2010};
- std::cout << timeprint(timesplit(first_half, erronious_splitpoint)) << "\n";
-
-
-
- std::cout << "\n\n --- TIME WINDING TEST ---\n\n";
-
- moment testtime{30, 8, 25, 2, 2012};
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
-
- std::cout << "\nForwarding 45 minutes...\n";
- wind(testtime, 45, 0, 0);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
- std::cout << "\nRewinding 45 minutes...\n";
- wind(testtime, -45, 0, 0);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
-
- std::cout << "\nForwarding 20 hours...\n";
- wind(testtime, 0, 20, 0);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
- std::cout << "\nRewinding 20 hours...\n";
- wind(testtime, 0, -20, 0);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
-
- std::cout << "\nForwarding 10 days...\n";
- wind(testtime, 0, 0, 10);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
- std::cout << "\nRewinding 10 days...\n";
- wind(testtime, 0, 0, -10);
- std::cout << "Testtime: " << timeprint(testtime) << std::endl;
-
-
-
- std::cout << "\n\n --- TIME INPUT TEST ---\n\n";
-
- moment inputmoment = timeinput();
- std::cout << "Time reveived: " << timeprint(inputmoment) << std::endl;
- moment inputmoment2 = timeinput(2012, 11, 26);
- std::cout << "Time reveived: " << timeprint(inputmoment2) << std::endl;
+ test(); // Test time-stuff
}
} else {
std::cout << "satscalc (C++ Edition)\n";
diff --git a/src/test.cpp b/src/test.cpp
new file mode 100644
index 0000000..3d6d78b
--- /dev/null
+++ b/src/test.cpp
@@ -0,0 +1,83 @@
+#include "test.h"
+#include "time.h"
+
+void test(){
+ moment calltime{30, 8, 27, 11, 2010};
+ moment wraptime{30, 16, 27, 11, 2010};
+ timeblock workday{calltime, wraptime};
+
+ std::cout << "\n\n --- TIME UNITS TEST ---\n\n";
+ std::cout << "Calltime: " << timeprint(calltime) << std::endl;
+ std::cout << "Wraptime: " << timeprint(wraptime) << std::endl;
+
+ std::cout << "\nWorkday:\n";
+ std::cout << timeprint(workday) << std::endl;
+
+
+
+ std::cout << "\n\n --- TIME MATH TEST ---\n\n";
+
+ std::cout << "Difference between calltime and wraptime:\n";
+ std::cout << (calltime-wraptime) << std::endl;
+ std::cout << "Other way around, should show same result:\n";
+ std::cout << (calltime-wraptime) << std::endl;
+ std::cout << "As method on workday:\n";
+ std::cout << (workday.hourcount()) << std::endl;
+
+ std::cout << "\nSplitting workday into workday and second_half...\n";
+ moment splitpoint{0, 12, 27, 11, 2010};
+ timeblock first_half{timesplit(workday, splitpoint)};
+
+ std::cout << "\nSplitpoint: " << timeprint(splitpoint) << std::endl;
+ std::cout << "\nfirst_half:\n";
+ std::cout << timeprint(first_half) << std::endl;
+ std::cout << "\nWorkday:\n";
+ std::cout << timeprint(workday) << std::endl;
+
+ std::cout << "\nSplitting second_half at erronious point...\n";
+ moment erronious_splitpoint{0, 14, 27, 11, 2010};
+ std::cout << timeprint(timesplit(first_half, erronious_splitpoint)) << "\n";
+
+
+
+ std::cout << "\n\n --- TIME WINDING TEST ---\n\n";
+
+ moment testtime{30, 8, 25, 2, 2012};
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+
+ std::cout << "\nForwarding 45 minutes...\n";
+ wind(testtime, 45, 0, 0);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+ std::cout << "\nRewinding 45 minutes...\n";
+ wind(testtime, -45, 0, 0);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+
+ std::cout << "\nForwarding 20 hours...\n";
+ wind(testtime, 0, 20, 0);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+ std::cout << "\nRewinding 20 hours...\n";
+ wind(testtime, 0, -20, 0);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+
+ std::cout << "\nForwarding 10 days...\n";
+ wind(testtime, 0, 0, 10);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+ std::cout << "\nRewinding 10 days...\n";
+ wind(testtime, 0, 0, -10);
+ std::cout << "Testtime: " << timeprint(testtime) << std::endl;
+
+
+
+ std::cout << "\n\n --- TIME INPUT TEST ---\n\n";
+
+ moment inputmoment = timeinput();
+ std::cout << "Time reveived: " << timeprint(inputmoment) << std::endl;
+ moment inputmoment2 = timeinput(2012, 11, 26);
+ std::cout << "Time reveived: " << timeprint(inputmoment2) << std::endl;
+}
diff --git a/src/test.h b/src/test.h
new file mode 100644
index 0000000..bf54737
--- /dev/null
+++ b/src/test.h
@@ -0,0 +1,6 @@
+#pragma once
+#include <time.h>
+#include <string.h>
+#include <iostream>
+
+void test();
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..3a05bbd
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,12 @@
+./a.out <<EOF-MARKER
+2022 11 20 08 00
+2022 11 21 02 00
+2022 11 20 19 45
+2022 11 22 08 30
+2022 11 22 19 30
+2022 11 22 19 00
+2022 11 24 14 00
+2022 11 24 23 30
+2022 11 24 23 00
+EOF-MARKER
+