2 * This file is part of mutest, a simple micro unit testing framework for C.
4 * mutest was written by Leandro Lucarella <llucax@gmail.com> and is released
5 * under the BOLA license, please see the LICENSE file or visit:
6 * http://blitiri.com.ar/p/bola/
8 * This is a C++ module test suite. It shows how to use checks involving
11 * Please, read the README file for more details.
14 #include <stdexcept> // std::out_of_range
15 #include <vector> // std::vector
17 #include "../mutest.h"
21 void mu_test_exceptions() {
22 std::vector<int> v(1);
24 mu_check(v.at(0) == 0);
26 mu_check(v.at(1) == 0);
27 // ok, we expect the exception to be thrown, and it does
28 mu_echeck(std::out_of_range, v.at(1));
29 // fails! We expect this to throw, but it doesn't
30 mu_echeck(std::out_of_range, v.at(0));
31 // fails again, but this time the show is over (note the "ensure")
32 mu_eensure(std::out_of_range, v.at(0));
33 // this will never be executed (it should fail if it is)