ProteoWizard
ExceptionTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6//
7// Copyright 2008 Vanderbilt University - Nashville, TN 37232
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
22
23#include "Std.hpp"
24#include "Exception.hpp"
25#include "unit.hpp"
26#include <cassert>
27
28
29using namespace pwiz::util;
30
31
32ostream* os_ = 0;
33
34
35void test()
36{
37#ifndef NDEBUG
38 boost::shared_ptr<int> foo;
39 unit_assert_throws(*foo, runtime_error);
40#endif
41
42#ifdef _DEBUG
43 unit_assert_throws(_ASSERTE(1+1 == 4), runtime_error);
44#endif
45}
46
47
48int main(int argc, char* argv[])
49{
50 TEST_PROLOG(argc, argv)
51
52 try
53 {
54 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
55 if (os_) *os_ << "ExceptionTest\n";
56 test();
57 }
58 catch (exception& e)
59 {
60 TEST_FAILED(e.what())
61 }
62 catch (...)
63 {
64 TEST_FAILED("Caught unknown exception.")
65 }
66
68}
int main(int argc, char *argv[])
ostream * os_
void test()
#define unit_assert_throws(x, exception)
Definition unit.hpp:106
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175