about summary refs log tree commit diff
path: root/lang/cpptour/Vector-test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpptour/Vector-test.cc')
-rw-r--r--lang/cpptour/Vector-test.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/lang/cpptour/Vector-test.cc b/lang/cpptour/Vector-test.cc
new file mode 100644
index 0000000..fbdf129
--- /dev/null
+++ b/lang/cpptour/Vector-test.cc
@@ -0,0 +1,29 @@
+#include <cassert>
+#include <iostream>
+#include <stdexcept>
+
+#include "Vector.h"
+
+using namespace std;
+
+void
+neg_length ()
+{
+  try { Vector v (-27); }
+  catch (length_error) { cout << "it's alright" << endl; }
+  catch (bad_alloc) { cout << "BIG OOF!" << endl; }
+}
+
+void
+init ()
+{
+  Vector v {7.4, 3.2, 5.2, 6.9, 9.5, 4.2, 21.7};
+  assert(v[5] == 4.2);
+}
+
+int
+main ()
+{
+  neg_length ();
+  init ();
+}