aboutsummaryrefslogtreecommitdiff
path: root/test/unit/notsosimplevector.cc
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2023-12-12 21:27:08 +0100
committerRodrigo Arias Mallo <rodrigo.arias@bsc.es>2023-12-21 01:05:58 +0100
commit1da1260af72b20126176e2b8f73f7b7fd5952ce1 (patch)
tree0fcdb276d30814ce4075f7cc205e357b2b7c1be5 /test/unit/notsosimplevector.cc
parent78ad5bfe9644d1217f9d9ad0bf2fcdc388551113 (diff)
Split tests into unit and dw (graphical)
Graphical tests for the dw (Dillo Widget) are moved to test/dw, while unit tests are placed into test/unit. All tests are compiled with "make check" but only the tests that can run without intervention and without a graphic display are executed.
Diffstat (limited to 'test/unit/notsosimplevector.cc')
-rw-r--r--test/unit/notsosimplevector.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/unit/notsosimplevector.cc b/test/unit/notsosimplevector.cc
new file mode 100644
index 00000000..d41288fb
--- /dev/null
+++ b/test/unit/notsosimplevector.cc
@@ -0,0 +1,63 @@
+#include "../lout/misc.hh"
+
+static void print (lout::misc::NotSoSimpleVector<int> *v)
+{
+ for (int i = 0; i < v->size(); i++) {
+ // Uncomment for debugging, after making the respective members public.
+ //if (v->startExtra != -1 && i == v->startExtra + v->numExtra)
+ // printf (" ]");
+ if (i > 0)
+ printf (", ");
+ //if (i == v->startExtra)
+ // printf ("[ ");
+
+ printf ("%d", v->get(i));
+ }
+
+ printf (" (%d elements)\n", v->size ());
+}
+
+int main (int argc, char *argv[])
+{
+ lout::misc::NotSoSimpleVector<int> v(1);
+
+ for (int i = 1; i <= 10; i++) {
+ v.increase ();
+ v.set(v.size () - 1, i);
+ }
+
+ print (&v);
+
+ v.insert (2, 4);
+ for (int i = 0; i < 5; i++)
+ v.set (2 + i, 31 + i);
+
+ print (&v);
+
+ v.insert (8, 4);
+ for (int i = 0; i < 5; i++)
+ v.set (8 + i, 51 + i);
+
+ print (&v);
+
+ v.insert (10, 4);
+ for (int i = 0; i < 5; i++)
+ v.set (10 + i, 531 + i);
+
+ print (&v);
+
+ v.insert (1, 4);
+ for (int i = 0; i < 5; i++)
+ v.set (1 + i, 21 + i);
+
+ print (&v);
+
+ int n = v.size ();
+ v.insert (n, 5);
+ for (int i = 0; i < 5; i++)
+ v.set (n + i, 101 + i);
+
+ print (&v);
+
+ return 0;
+}