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 
29 using namespace pwiz::util;
30 
31 
32 ostream* os_ = 0;
33 
34 
35 void 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 
48 int 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 }
unit_assert_throws
#define unit_assert_throws(x, exception)
Definition: unit.hpp:106
Exception.hpp
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
test
void test()
Definition: ExceptionTest.cpp:35
os_
ostream * os_
Definition: ExceptionTest.cpp:32
Std.hpp
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
main
int main(int argc, char *argv[])
Definition: ExceptionTest.cpp:48
unit.hpp