aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am7
-rw-r--r--test/notsosimplevector.cc49
2 files changed, 55 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 425a11a8..15ab227b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -22,7 +22,8 @@ noinst_PROGRAMS = \
fltk-browser \
shapes \
cookies \
- liang
+ liang \
+ notsosimplevector
dw_anchors_test_SOURCES = dw_anchors_test.cc
dw_anchors_test_LDADD = \
@@ -169,3 +170,7 @@ liang_LDADD = \
$(top_builddir)/dw/libDw-core.a \
$(top_builddir)/lout/liblout.a \
@LIBFLTK_LIBS@
+
+notsosimplevector_SOURCES = notsosimplevector.cc
+
+notsosimplevector_LDADD = $(top_builddir)/lout/liblout.a
diff --git a/test/notsosimplevector.cc b/test/notsosimplevector.cc
new file mode 100644
index 00000000..6f27287b
--- /dev/null
+++ b/test/notsosimplevector.cc
@@ -0,0 +1,49 @@
+#include "../lout/misc.hh"
+
+static void print (lout::misc::NotSoSimpleVector<int> *v)
+{
+ for (int i = 0; i < v->size(); i++) {
+ if (i > 0)
+ printf (", ");
+ printf ("%d", v->get(i));
+ }
+ printf ("\n");
+}
+
+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);
+
+ return 0;
+}