about summary refs log tree commit diff
path: root/lang/cpptour/Vector-test.cc
blob: fbdf12921c63846678d8a6c88392abfd5479d66d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 ();
}