summaryrefslogtreecommitdiff
path: root/test/datastructures
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-09-05 14:20:50 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-09-05 14:20:50 +0200
commit65e5812f5b88989ea3ce4ac232f882004c60cc73 (patch)
tree996dad7bde7338ed95835cf8a39d5520b58c8fa0 /test/datastructures
parent1abc08be606b7379bb1b9c5150bf73841a4b9c66 (diff)
more tests
Diffstat (limited to 'test/datastructures')
-rw-r--r--test/datastructures/dynamicConvexHull.cpp2
-rw-r--r--test/datastructures/stlPriorityQueue.cpp6
-rw-r--r--test/datastructures/stlPriorityQueue.cpp.awk37
-rw-r--r--test/datastructures/stlRope.cpp6
-rw-r--r--test/datastructures/stlRope.cpp.awk27
5 files changed, 77 insertions, 1 deletions
diff --git a/test/datastructures/dynamicConvexHull.cpp b/test/datastructures/dynamicConvexHull.cpp
index f163397..e0345af 100644
--- a/test/datastructures/dynamicConvexHull.cpp
+++ b/test/datastructures/dynamicConvexHull.cpp
@@ -55,7 +55,7 @@ void performance_test() {
hash += hd.query(x);
t.stop();
}
- if (t.time > 100) cerr << "too slow: " << t.time << FAIL;
+ if (t.time > 200) cerr << "too slow: " << t.time << FAIL;
cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl;
}
diff --git a/test/datastructures/stlPriorityQueue.cpp b/test/datastructures/stlPriorityQueue.cpp
new file mode 100644
index 0000000..669f4d4
--- /dev/null
+++ b/test/datastructures/stlPriorityQueue.cpp
@@ -0,0 +1,6 @@
+#include "../util.h"
+#include <datastructures/stlPriorityQueue.cpp>
+
+int main() {
+ test();
+} \ No newline at end of file
diff --git a/test/datastructures/stlPriorityQueue.cpp.awk b/test/datastructures/stlPriorityQueue.cpp.awk
new file mode 100644
index 0000000..99d0fb9
--- /dev/null
+++ b/test/datastructures/stlPriorityQueue.cpp.awk
@@ -0,0 +1,37 @@
+/auto/ {
+ print "void test() {"
+ print "pQueue<ll> pq, pq2;"
+ print "pq.push(1);"
+ print "pq.push(5);"
+ print "pq.push(7);"
+ print "pq2.push(2);"
+ print "pq2.push(4);"
+ print "pq2.push(8);"
+}
+END {
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 8) cerr << \"error, got: \" << pq.top() << \", expected: 8\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 7) cerr << \"error, got: \" << pq.top() << \", expected: 7\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 6) cerr << \"error, got: \" << pq.top() << \", expected: 6\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 5) cerr << \"error, got: \" << pq.top() << \", expected: 5\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 4) cerr << \"error, got: \" << pq.top() << \", expected: 4\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 2) cerr << \"error, got: \" << pq.top() << \", expected: 2\" << FAIL;"
+ print "pq.pop();"
+ print "if (pq.empty()) cerr << \"error: empty\" << FAIL;"
+ print "if (pq.top() != 1) cerr << \"error, got: \" << pq.top() << \", expected: 1\" << FAIL;"
+ print "pq.pop();"
+ print "if (!pq.empty()) cerr << \"error, got: \" << pq.top() << \", expected: empty\" << FAIL;"
+ print "cerr << \"testes example\" << endl;"
+ print "}"
+}
+{ print }
diff --git a/test/datastructures/stlRope.cpp b/test/datastructures/stlRope.cpp
new file mode 100644
index 0000000..669f4d4
--- /dev/null
+++ b/test/datastructures/stlRope.cpp
@@ -0,0 +1,6 @@
+#include "../util.h"
+#include <datastructures/stlPriorityQueue.cpp>
+
+int main() {
+ test();
+} \ No newline at end of file
diff --git a/test/datastructures/stlRope.cpp.awk b/test/datastructures/stlRope.cpp.awk
new file mode 100644
index 0000000..e19b8fd
--- /dev/null
+++ b/test/datastructures/stlRope.cpp.awk
@@ -0,0 +1,27 @@
+/rope<int> v;/ {
+ print "void test() {"
+ print "ll num = 5;"
+ print "ll start = 2;"
+ print "ll length = 4;"
+ print "ll offset = 3;"
+}
+/v.push_back(num);/ {
+ print "v.push_back(0);"
+ print "v.push_back(1);"
+ print "v.push_back(2);"
+ print "v.push_back(3);"
+ print "v.push_back(4);"
+}
+/rope<int> sub/ {
+ print "v.push_back(6);"
+ print "v.push_back(7);"
+}
+/for\(auto it/ {
+ print "vector<int> got, expected = {0,1,6,2,3,4,5,7};"
+}
+END {
+ print " got.push_back(*it)"
+ print "if (got != expected) cerr << \"error\" << endl;"
+ print "}"
+}
+{ print }