annotate include/catch.hpp @ 1228:5654c9173548

merged (bicycle)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 12 Jul 2023 13:21:08 -0400
parents c6f497291fd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1 /*
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2 * Catch v1.5.6
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3 * Generated: 2016-06-09 19:20:41.460328
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4 * ----------------------------------------------------------
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 * This file has been merged from multiple headers. Please don't edit it directly
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6 * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7 *
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8 * Distributed under the Boost Software License, Version 1.0. (See accompanying
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10 */
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
11 #ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
12 #define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
14 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
15
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
16 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
17 # pragma clang system_header
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
18 #elif defined __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
19 # pragma GCC system_header
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
20 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
21
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
22 // #included from: internal/catch_suppress_warnings.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
23
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
24 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
25 # ifdef __ICC // icpc defines the __clang__ macro
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
26 # pragma warning(push)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
27 # pragma warning(disable: 161 1682)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
28 # else // __ICC
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
29 # pragma clang diagnostic ignored "-Wglobal-constructors"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
30 # pragma clang diagnostic ignored "-Wvariadic-macros"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
31 # pragma clang diagnostic ignored "-Wc99-extensions"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
32 # pragma clang diagnostic ignored "-Wunused-variable"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
33 # pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
34 # pragma clang diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
35 # pragma clang diagnostic ignored "-Wc++98-compat"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
36 # pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
37 # pragma clang diagnostic ignored "-Wswitch-enum"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
38 # pragma clang diagnostic ignored "-Wcovered-switch-default"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
39 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
40 #elif defined __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
41 # pragma GCC diagnostic ignored "-Wvariadic-macros"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
42 # pragma GCC diagnostic ignored "-Wunused-variable"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
43 # pragma GCC diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
44 # pragma GCC diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
45 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
46 #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
47 # define CATCH_IMPL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
48 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
49
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
50 #ifdef CATCH_IMPL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
51 # ifndef CLARA_CONFIG_MAIN
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
52 # define CLARA_CONFIG_MAIN_NOT_DEFINED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
53 # define CLARA_CONFIG_MAIN
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
54 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
55 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
56
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
57 // #included from: internal/catch_notimplemented_exception.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
58 #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
59
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
60 // #included from: catch_common.h
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
61 #define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
62
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
63 #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
64 #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
65 #ifdef CATCH_CONFIG_COUNTER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
66 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
67 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
68 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
69 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
70
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
71 #define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
72 #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
73
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
74 #include <sstream>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
75 #include <stdexcept>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
76 #include <algorithm>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
77
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
78 // #included from: catch_compiler_capabilities.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
79 #define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
80
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
81 // Detect a number of compiler features - mostly C++11/14 conformance - by compiler
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
82 // The following features are defined:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
83 //
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
84 // CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
85 // CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
86 // CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
87 // CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
88 // CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
89 // CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
90 // CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
91 // CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
92
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
93 // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
94
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
95 // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
96 // CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
97 // ****************
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
98 // Note to maintainers: if new toggles are added please document them
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
99 // in configuration.md, too
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
100 // ****************
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
101
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
102 // In general each macro has a _NO_<feature name> form
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
103 // (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
104 // Many features, at point of detection, define an _INTERNAL_ macro, so they
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
105 // can be combined, en-mass, with the _NO_ forms later.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
106
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
107 // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
108
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
109 #ifdef __cplusplus
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
110
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
111 # if __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
112 # define CATCH_CPP11_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
113 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
114
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
115 # if __cplusplus >= 201402L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
116 # define CATCH_CPP14_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
117 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
118
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
119 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
120
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
121 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
122
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
123 # if __has_feature(cxx_nullptr)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
124 # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
125 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
126
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
127 # if __has_feature(cxx_noexcept)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
128 # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
129 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
130
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
131 # if defined(CATCH_CPP11_OR_GREATER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
132 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
133 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
134
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
135 #endif // __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
136
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
137 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
138 // Borland
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
139 #ifdef __BORLANDC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
140
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
141 #endif // __BORLANDC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
142
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
143 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
144 // EDG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
145 #ifdef __EDG_VERSION__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
146
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
147 #endif // __EDG_VERSION__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
148
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
149 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
150 // Digital Mars
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
151 #ifdef __DMC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
152
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
153 #endif // __DMC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
154
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
155 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
156 // GCC
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
157 #ifdef __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
158
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
159 # if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
160 # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
161 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
162
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
163 # if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
164 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
165 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
166
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
167 // - otherwise more recent versions define __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
168 // and will get picked up below
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
169
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
170 #endif // __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
171
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
172 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
173 // Visual C++
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
174 #ifdef _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
175
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
176 #if (_MSC_VER >= 1600)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
177 # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
178 # define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
179 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
180
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
181 #if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
182 #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
183 #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
184 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
185
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
186 #endif // _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
187
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
188 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
189
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
190 // Use variadic macros if the compiler supports them
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
191 #if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
192 ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
193 ( defined __GNUC__ && __GNUC__ >= 3 ) || \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
194 ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
195
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
196 #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
197
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
198 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
199
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
200 // Use __COUNTER__ if the compiler supports it
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
201 #if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
202 ( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
203 ( defined __clang__ && __clang_major__ >= 3 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
204
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
205 #define CATCH_INTERNAL_CONFIG_COUNTER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
206
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
207 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
208
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
209 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
210 // C++ language feature support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
211
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
212 // catch all support for C++11
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
213 #if defined(CATCH_CPP11_OR_GREATER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
214
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
215 # if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
216 # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
217 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
218
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
219 # ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
220 # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
221 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
222
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
223 # ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
224 # define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
225 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
226
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
227 # ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
228 # define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
229 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
230
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
231 # ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
232 # define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
233 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
234
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
235 # ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
236 # define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
237 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
238
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
239 # if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
240 # define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
241 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
242
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
243 # if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
244 # define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
245 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
246 # if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
247 # define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
248 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
249
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
250 #endif // __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
251
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
252 // Now set the actual defines based on the above + anything the user has configured
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
253 #if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
254 # define CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
255 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
256 #if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
257 # define CATCH_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
258 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
259 #if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
260 # define CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
261 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
262 #if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
263 # define CATCH_CONFIG_CPP11_IS_ENUM
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
264 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
265 #if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
266 # define CATCH_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
267 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
268 #if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
269 # define CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
270 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
271 #if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
272 # define CATCH_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
273 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
274 #if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
275 # define CATCH_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
276 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
277 #if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
278 # define CATCH_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
279 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
280 #if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
281 # define CATCH_CONFIG_COUNTER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
282 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
283
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
284 #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
285 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
286 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
287
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
288 // noexcept support:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
289 #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
290 # define CATCH_NOEXCEPT noexcept
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
291 # define CATCH_NOEXCEPT_IS(x) noexcept(x)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
292 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
293 # define CATCH_NOEXCEPT throw()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
294 # define CATCH_NOEXCEPT_IS(x)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
295 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
296
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
297 // nullptr support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
298 #ifdef CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
299 # define CATCH_NULL nullptr
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
300 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
301 # define CATCH_NULL NULL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
302 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
303
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
304 // override support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
305 #ifdef CATCH_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
306 # define CATCH_OVERRIDE override
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
307 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
308 # define CATCH_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
309 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
310
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
311 // unique_ptr support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
312 #ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
313 # define CATCH_AUTO_PTR( T ) std::unique_ptr<T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
314 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
315 # define CATCH_AUTO_PTR( T ) std::auto_ptr<T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
316 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
317
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
318 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
319
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
320 struct IConfig;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
321
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
322 struct CaseSensitive { enum Choice {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
323 Yes,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
324 No
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
325 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
326
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
327 class NonCopyable {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
328 #ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
329 NonCopyable( NonCopyable const& ) = delete;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
330 NonCopyable( NonCopyable && ) = delete;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
331 NonCopyable& operator = ( NonCopyable const& ) = delete;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
332 NonCopyable& operator = ( NonCopyable && ) = delete;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
333 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
334 NonCopyable( NonCopyable const& info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
335 NonCopyable& operator = ( NonCopyable const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
336 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
337
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
338 protected:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
339 NonCopyable() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
340 virtual ~NonCopyable();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
341 };
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
342
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
343 class SafeBool {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
344 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
345 typedef void (SafeBool::*type)() const;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
346
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
347 static type makeSafe( bool value ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
348 return value ? &SafeBool::trueValue : 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
349 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
350 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
351 void trueValue() const {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
352 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
353
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
354 template<typename ContainerT>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
355 inline void deleteAll( ContainerT& container ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
356 typename ContainerT::const_iterator it = container.begin();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
357 typename ContainerT::const_iterator itEnd = container.end();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
358 for(; it != itEnd; ++it )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
359 delete *it;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
360 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
361 template<typename AssociativeContainerT>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
362 inline void deleteAllValues( AssociativeContainerT& container ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
363 typename AssociativeContainerT::const_iterator it = container.begin();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
364 typename AssociativeContainerT::const_iterator itEnd = container.end();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
365 for(; it != itEnd; ++it )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
366 delete it->second;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
367 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
368
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
369 bool startsWith( std::string const& s, std::string const& prefix );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
370 bool endsWith( std::string const& s, std::string const& suffix );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
371 bool contains( std::string const& s, std::string const& infix );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
372 void toLowerInPlace( std::string& s );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
373 std::string toLower( std::string const& s );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
374 std::string trim( std::string const& str );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
375 bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
376
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
377 struct pluralise {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
378 pluralise( std::size_t count, std::string const& label );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
379
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
380 friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
381
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
382 std::size_t m_count;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
383 std::string m_label;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
384 };
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
385
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
386 struct SourceLineInfo {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
387
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
388 SourceLineInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
389 SourceLineInfo( char const* _file, std::size_t _line );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
390 SourceLineInfo( SourceLineInfo const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
391 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
392 SourceLineInfo( SourceLineInfo && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
393 SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
394 SourceLineInfo& operator = ( SourceLineInfo && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
395 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
396 bool empty() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
397 bool operator == ( SourceLineInfo const& other ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
398 bool operator < ( SourceLineInfo const& other ) const;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
399
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
400 std::string file;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
401 std::size_t line;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
402 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
403
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
404 std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
405
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
406 // This is just here to avoid compiler warnings with macro constants and boolean literals
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
407 inline bool isTrue( bool value ){ return value; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
408 inline bool alwaysTrue() { return true; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
409 inline bool alwaysFalse() { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
410
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
411 void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
412
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
413 void seedRng( IConfig const& config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
414 unsigned int rngSeed();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
415
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
416 // Use this in variadic streaming macros to allow
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
417 // >> +StreamEndStop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
418 // as well as
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
419 // >> stuff +StreamEndStop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
420 struct StreamEndStop {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
421 std::string operator+() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
422 return std::string();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
423 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
424 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
425 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
426 T const& operator + ( T const& value, StreamEndStop ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
427 return value;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
428 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
429 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
430
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
431 #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
432 #define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
433
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
434 #include <ostream>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
435
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
436 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
437
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
438 class NotImplementedException : public std::exception
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
439 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
440 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
441 NotImplementedException( SourceLineInfo const& lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
442 NotImplementedException( NotImplementedException const& ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
443
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
444 virtual ~NotImplementedException() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
445
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
446 virtual const char* what() const CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
447
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
448 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
449 std::string m_what;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
450 SourceLineInfo m_lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
451 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
452
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
453 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
454
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
455 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
456 #define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
457
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
458 // #included from: internal/catch_context.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
459 #define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
460
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
461 // #included from: catch_interfaces_generators.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
462 #define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
463
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
464 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
465
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
466 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
467
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
468 struct IGeneratorInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
469 virtual ~IGeneratorInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
470 virtual bool moveNext() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
471 virtual std::size_t getCurrentIndex() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
472 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
473
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
474 struct IGeneratorsForTest {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
475 virtual ~IGeneratorsForTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
476
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
477 virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
478 virtual bool moveNext() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
479 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
480
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
481 IGeneratorsForTest* createGeneratorsForTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
482
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
483 } // end namespace Catch
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
484
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
485 // #included from: catch_ptr.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
486 #define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
487
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
488 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
489 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
490 #pragma clang diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
491 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
492
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
493 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
494
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
495 // An intrusive reference counting smart pointer.
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
496 // T must implement addRef() and release() methods
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
497 // typically implementing the IShared interface
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
498 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
499 class Ptr {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
500 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
501 Ptr() : m_p( CATCH_NULL ){}
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
502 Ptr( T* p ) : m_p( p ){
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
503 if( m_p )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
504 m_p->addRef();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
505 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
506 Ptr( Ptr const& other ) : m_p( other.m_p ){
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
507 if( m_p )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
508 m_p->addRef();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
509 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
510 ~Ptr(){
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
511 if( m_p )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
512 m_p->release();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
513 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
514 void reset() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
515 if( m_p )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
516 m_p->release();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
517 m_p = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
518 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
519 Ptr& operator = ( T* p ){
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
520 Ptr temp( p );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
521 swap( temp );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
522 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
523 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
524 Ptr& operator = ( Ptr const& other ){
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
525 Ptr temp( other );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
526 swap( temp );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
527 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
528 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
529 void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
530 T* get() const{ return m_p; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
531 T& operator*() const { return *m_p; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
532 T* operator->() const { return m_p; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
533 bool operator !() const { return m_p == CATCH_NULL; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
534 operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
535
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
536 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
537 T* m_p;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
538 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
539
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
540 struct IShared : NonCopyable {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
541 virtual ~IShared();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
542 virtual void addRef() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
543 virtual void release() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
544 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
545
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
546 template<typename T = IShared>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
547 struct SharedImpl : T {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
548
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
549 SharedImpl() : m_rc( 0 ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
550
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
551 virtual void addRef() const {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
552 ++m_rc;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
553 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
554 virtual void release() const {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
555 if( --m_rc == 0 )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
556 delete this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
557 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
558
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
559 mutable unsigned int m_rc;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
560 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
561
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
562 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
563
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
564 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
565 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
566 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
567
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
568 #include <memory>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
569 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
570 #include <stdlib.h>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
571
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
572 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
573
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
574 class TestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
575 class Stream;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
576 struct IResultCapture;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
577 struct IRunner;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
578 struct IGeneratorsForTest;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
579 struct IConfig;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
580
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
581 struct IContext
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
582 {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
583 virtual ~IContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
584
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
585 virtual IResultCapture* getResultCapture() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
586 virtual IRunner* getRunner() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
587 virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
588 virtual bool advanceGeneratorsForCurrentTest() = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
589 virtual Ptr<IConfig const> getConfig() const = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
590 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
591
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
592 struct IMutableContext : IContext
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
593 {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
594 virtual ~IMutableContext();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
595 virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
596 virtual void setRunner( IRunner* runner ) = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
597 virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
598 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
599
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
600 IContext& getCurrentContext();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
601 IMutableContext& getCurrentMutableContext();
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
602 void cleanUpContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
603 Stream createStream( std::string const& streamName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
604
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
605 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
606
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
607 // #included from: internal/catch_test_registry.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
608 #define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
609
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
610 // #included from: catch_interfaces_testcase.h
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
611 #define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
612
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
613 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
614
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
615 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
616
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
617 class TestSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
618
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
619 struct ITestCase : IShared {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
620 virtual void invoke () const = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
621 protected:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
622 virtual ~ITestCase();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
623 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
624
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
625 class TestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
626 struct IConfig;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
627
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
628 struct ITestCaseRegistry {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
629 virtual ~ITestCaseRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
630 virtual std::vector<TestCase> const& getAllTests() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
631 virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
632 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
633
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
634 bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
635 std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
636 std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
637
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
638 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
639
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
640 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
641
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
642 template<typename C>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
643 class MethodTestCase : public SharedImpl<ITestCase> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
644
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
645 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
646 MethodTestCase( void (C::*method)() ) : m_method( method ) {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
647
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
648 virtual void invoke() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
649 C obj;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
650 (obj.*m_method)();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
651 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
652
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
653 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
654 virtual ~MethodTestCase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
655
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
656 void (C::*m_method)();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
657 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
658
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
659 typedef void(*TestFunction)();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
660
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
661 struct NameAndDesc {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
662 NameAndDesc( const char* _name = "", const char* _description= "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
663 : name( _name ), description( _description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
664 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
665
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
666 const char* name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
667 const char* description;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
668 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
669
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
670 void registerTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
671 ( ITestCase* testCase,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
672 char const* className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
673 NameAndDesc const& nameAndDesc,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
674 SourceLineInfo const& lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
675
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
676 struct AutoReg {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
677
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
678 AutoReg
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
679 ( TestFunction function,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
680 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
681 NameAndDesc const& nameAndDesc );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
682
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
683 template<typename C>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
684 AutoReg
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
685 ( void (C::*method)(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
686 char const* className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
687 NameAndDesc const& nameAndDesc,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
688 SourceLineInfo const& lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
689
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
690 registerTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
691 ( new MethodTestCase<C>( method ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
692 className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
693 nameAndDesc,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
694 lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
695 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
696
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
697 ~AutoReg();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
698
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
699 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
700 AutoReg( AutoReg const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
701 void operator= ( AutoReg const& );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
702 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
703
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
704 void registerTestCaseFunction
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
705 ( TestFunction function,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
706 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
707 NameAndDesc const& nameAndDesc );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
708
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
709 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
710
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
711 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
712 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
713 #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
714 static void TestName(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
715 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
716 static void TestName()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
717 #define INTERNAL_CATCH_TESTCASE( ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
718 INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
719
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
720 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
721 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
722 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
723
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
724 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
725 #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
726 namespace{ \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
727 struct TestName : ClassName{ \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
728 void test(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
729 }; \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
730 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
731 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
732 void TestName::test()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
733 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
734 INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
735
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
736 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
737 #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
738 Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
739
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
740 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
741 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
742 #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
743 static void TestName(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
744 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
745 static void TestName()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
746 #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
747 INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
748
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
749 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
750 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
751 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
752
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
753 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
754 #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
755 namespace{ \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
756 struct TestCaseName : ClassName{ \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
757 void test(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
758 }; \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
759 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
760 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
761 void TestCaseName::test()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
762 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
763 INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
764
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
765 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
766 #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
767 Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
768 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
769
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
770 // #included from: internal/catch_capture.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
771 #define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
772
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
773 // #included from: catch_result_builder.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
774 #define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
775
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
776 // #included from: catch_result_type.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
777 #define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
778
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
779 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
780
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
781 // ResultWas::OfType enum
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
782 struct ResultWas { enum OfType {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
783 Unknown = -1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
784 Ok = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
785 Info = 1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
786 Warning = 2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
787
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
788 FailureBit = 0x10,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
789
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
790 ExpressionFailed = FailureBit | 1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
791 ExplicitFailure = FailureBit | 2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
792
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
793 Exception = 0x100 | FailureBit,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
794
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
795 ThrewException = Exception | 1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
796 DidntThrowException = Exception | 2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
797
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
798 FatalErrorCondition = 0x200 | FailureBit
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
799
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
800 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
801
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
802 inline bool isOk( ResultWas::OfType resultType ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
803 return ( resultType & ResultWas::FailureBit ) == 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
804 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
805 inline bool isJustInfo( int flags ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
806 return flags == ResultWas::Info;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
807 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
808
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
809 // ResultDisposition::Flags enum
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
810 struct ResultDisposition { enum Flags {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
811 Normal = 0x01,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
812
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
813 ContinueOnFailure = 0x02, // Failures fail test, but execution continues
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
814 FalseTest = 0x04, // Prefix expression with !
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
815 SuppressFail = 0x08 // Failures are reported but do not fail the test
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
816 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
817
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
818 inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
819 return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
820 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
821
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
822 inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
823 inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
824 inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
825
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
826 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
827
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
828 // #included from: catch_assertionresult.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
829 #define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
830
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
831 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
832
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
833 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
834
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
835 struct AssertionInfo
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
836 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
837 AssertionInfo() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
838 AssertionInfo( std::string const& _macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
839 SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
840 std::string const& _capturedExpression,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
841 ResultDisposition::Flags _resultDisposition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
842
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
843 std::string macroName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
844 SourceLineInfo lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
845 std::string capturedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
846 ResultDisposition::Flags resultDisposition;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
847 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
848
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
849 struct AssertionResultData
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
850 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
851 AssertionResultData() : resultType( ResultWas::Unknown ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
852
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
853 std::string reconstructedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
854 std::string message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
855 ResultWas::OfType resultType;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
856 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
857
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
858 class AssertionResult {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
859 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
860 AssertionResult();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
861 AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
862 ~AssertionResult();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
863 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
864 AssertionResult( AssertionResult const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
865 AssertionResult( AssertionResult && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
866 AssertionResult& operator = ( AssertionResult const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
867 AssertionResult& operator = ( AssertionResult && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
868 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
869
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
870 bool isOk() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
871 bool succeeded() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
872 ResultWas::OfType getResultType() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
873 bool hasExpression() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
874 bool hasMessage() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
875 std::string getExpression() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
876 std::string getExpressionInMacro() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
877 bool hasExpandedExpression() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
878 std::string getExpandedExpression() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
879 std::string getMessage() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
880 SourceLineInfo getSourceInfo() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
881 std::string getTestMacroName() const;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
882
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
883 protected:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
884 AssertionInfo m_info;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
885 AssertionResultData m_resultData;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
886 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
887
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
888 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
889
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
890 // #included from: catch_matchers.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
891 #define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
892
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
893 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
894 namespace Matchers {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
895 namespace Impl {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
896
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
897 namespace Generic {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
898 template<typename ExpressionT> class AllOf;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
899 template<typename ExpressionT> class AnyOf;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
900 template<typename ExpressionT> class Not;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
901 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
902
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
903 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
904 struct Matcher : SharedImpl<IShared>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
905 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
906 typedef ExpressionT ExpressionType;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
907
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
908 virtual ~Matcher() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
909 virtual Ptr<Matcher> clone() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
910 virtual bool match( ExpressionT const& expr ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
911 virtual std::string toString() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
912
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
913 Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
914 Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
915 Generic::Not<ExpressionT> operator ! () const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
916 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
917
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
918 template<typename DerivedT, typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
919 struct MatcherImpl : Matcher<ExpressionT> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
920
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
921 virtual Ptr<Matcher<ExpressionT> > clone() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
922 return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<DerivedT const&>( *this ) ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
923 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
924 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
925
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
926 namespace Generic {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
927 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
928 class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
929 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
930 explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
931 Not( Not const& other ) : m_matcher( other.m_matcher ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
932
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
933 virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
934 return !m_matcher->match( expr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
935 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
936
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
937 virtual std::string toString() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
938 return "not " + m_matcher->toString();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
939 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
940 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
941 Ptr< Matcher<ExpressionT> > m_matcher;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
942 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
943
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
944 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
945 class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
946 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
947
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
948 AllOf() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
949 AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
950
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
951 AllOf& add( Matcher<ExpressionT> const& matcher ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
952 m_matchers.push_back( matcher.clone() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
953 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
954 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
955 virtual bool match( ExpressionT const& expr ) const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
956 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
957 for( std::size_t i = 0; i < m_matchers.size(); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
958 if( !m_matchers[i]->match( expr ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
959 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
960 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
961 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
962 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
963 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
964 oss << "( ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
965 for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
966 if( i != 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
967 oss << " and ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
968 oss << m_matchers[i]->toString();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
969 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
970 oss << " )";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
971 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
972 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
973
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
974 AllOf operator && ( Matcher<ExpressionT> const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
975 AllOf allOfExpr( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
976 allOfExpr.add( other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
977 return allOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
978 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
979
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
980 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
981 std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
982 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
983
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
984 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
985 class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
986 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
987
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
988 AnyOf() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
989 AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
990
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
991 AnyOf& add( Matcher<ExpressionT> const& matcher ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
992 m_matchers.push_back( matcher.clone() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
993 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
994 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
995 virtual bool match( ExpressionT const& expr ) const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
996 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
997 for( std::size_t i = 0; i < m_matchers.size(); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
998 if( m_matchers[i]->match( expr ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
999 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1000 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1001 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1002 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1003 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1004 oss << "( ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1005 for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1006 if( i != 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1007 oss << " or ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1008 oss << m_matchers[i]->toString();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1009 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1010 oss << " )";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1011 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1012 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1013
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1014 AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1015 AnyOf anyOfExpr( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1016 anyOfExpr.add( other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1017 return anyOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1018 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1019
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1020 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1021 std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1022 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1023
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1024 } // namespace Generic
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1025
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1026 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1027 Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1028 Generic::AllOf<ExpressionT> allOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1029 allOfExpr.add( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1030 allOfExpr.add( other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1031 return allOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1032 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1033
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1034 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1035 Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1036 Generic::AnyOf<ExpressionT> anyOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1037 anyOfExpr.add( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1038 anyOfExpr.add( other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1039 return anyOfExpr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1040 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1041
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1042 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1043 Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1044 return Generic::Not<ExpressionT>( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1045 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1046
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1047 namespace StdString {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1048
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1049 inline std::string makeString( std::string const& str ) { return str; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1050 inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1051
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1052 struct CasedString
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1053 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1054 CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1055 : m_caseSensitivity( caseSensitivity ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1056 m_str( adjustString( str ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1057 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1058 std::string adjustString( std::string const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1059 return m_caseSensitivity == CaseSensitive::No
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1060 ? toLower( str )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1061 : str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1062
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1063 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1064 std::string toStringSuffix() const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1065 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1066 return m_caseSensitivity == CaseSensitive::No
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1067 ? " (case insensitive)"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1068 : "";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1069 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1070 CaseSensitive::Choice m_caseSensitivity;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1071 std::string m_str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1072 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1073
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1074 struct Equals : MatcherImpl<Equals, std::string> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1075 Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1076 : m_data( str, caseSensitivity )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1077 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1078 Equals( Equals const& other ) : m_data( other.m_data ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1079
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1080 virtual ~Equals();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1081
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1082 virtual bool match( std::string const& expr ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1083 return m_data.m_str == m_data.adjustString( expr );;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1084 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1085 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1086 return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1087 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1088
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1089 CasedString m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1090 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1091
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1092 struct Contains : MatcherImpl<Contains, std::string> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1093 Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1094 : m_data( substr, caseSensitivity ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1095 Contains( Contains const& other ) : m_data( other.m_data ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1096
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1097 virtual ~Contains();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1098
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1099 virtual bool match( std::string const& expr ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1100 return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1101 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1102 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1103 return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1104 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1105
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1106 CasedString m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1107 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1108
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1109 struct StartsWith : MatcherImpl<StartsWith, std::string> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1110 StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1111 : m_data( substr, caseSensitivity ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1112
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1113 StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1114
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1115 virtual ~StartsWith();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1116
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1117 virtual bool match( std::string const& expr ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1118 return startsWith( m_data.adjustString( expr ), m_data.m_str );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1119 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1120 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1121 return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1122 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1123
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1124 CasedString m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1125 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1126
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1127 struct EndsWith : MatcherImpl<EndsWith, std::string> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1128 EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1129 : m_data( substr, caseSensitivity ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1130 EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1131
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1132 virtual ~EndsWith();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1133
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1134 virtual bool match( std::string const& expr ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1135 return endsWith( m_data.adjustString( expr ), m_data.m_str );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1136 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1137 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1138 return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1139 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1140
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1141 CasedString m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1142 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1143 } // namespace StdString
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1144 } // namespace Impl
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1145
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1146 // The following functions create the actual matcher objects.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1147 // This allows the types to be inferred
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1148 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1149 inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<ExpressionT> const& m ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1150 return Impl::Generic::Not<ExpressionT>( m );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1151 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1152
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1153 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1154 inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1155 Impl::Matcher<ExpressionT> const& m2 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1156 return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1157 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1158 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1159 inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1160 Impl::Matcher<ExpressionT> const& m2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1161 Impl::Matcher<ExpressionT> const& m3 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1162 return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1163 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1164 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1165 inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1166 Impl::Matcher<ExpressionT> const& m2 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1167 return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1168 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1169 template<typename ExpressionT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1170 inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1171 Impl::Matcher<ExpressionT> const& m2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1172 Impl::Matcher<ExpressionT> const& m3 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1173 return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1174 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1175
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1176 inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1177 return Impl::StdString::Equals( str, caseSensitivity );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1178 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1179 inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1180 return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1181 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1182 inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1183 return Impl::StdString::Contains( substr, caseSensitivity );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1184 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1185 inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1186 return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1187 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1188 inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1189 return Impl::StdString::StartsWith( substr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1190 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1191 inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1192 return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1193 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1194 inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1195 return Impl::StdString::EndsWith( substr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1196 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1197 inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1198 return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1199 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1200
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1201 } // namespace Matchers
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1202
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1203 using namespace Matchers;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1204
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1205 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1206
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1207 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1208
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1209 struct TestFailureException{};
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1210
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1211 template<typename T> class ExpressionLhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1212
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1213 struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1214
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1215 struct CopyableStream {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1216 CopyableStream() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1217 CopyableStream( CopyableStream const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1218 oss << other.oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1219 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1220 CopyableStream& operator=( CopyableStream const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1221 oss.str("");
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1222 oss << other.oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1223 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1224 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1225 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1226 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1227
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1228 class ResultBuilder {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1229 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1230 ResultBuilder( char const* macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1231 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1232 char const* capturedExpression,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1233 ResultDisposition::Flags resultDisposition,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1234 char const* secondArg = "" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1235
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1236 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1237 ExpressionLhs<T const&> operator <= ( T const& operand );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1238 ExpressionLhs<bool> operator <= ( bool value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1239
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1240 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1241 ResultBuilder& operator << ( T const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1242 m_stream.oss << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1243 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1244 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1245
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1246 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1247 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1248
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1249 ResultBuilder& setResultType( ResultWas::OfType result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1250 ResultBuilder& setResultType( bool result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1251 ResultBuilder& setLhs( std::string const& lhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1252 ResultBuilder& setRhs( std::string const& rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1253 ResultBuilder& setOp( std::string const& op );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1254
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1255 void endExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1256
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1257 std::string reconstructExpression() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1258 AssertionResult build() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1259
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1260 void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1261 void captureResult( ResultWas::OfType resultType );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1262 void captureExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1263 void captureExpectedException( std::string const& expectedMessage );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1264 void captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1265 void handleResult( AssertionResult const& result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1266 void react();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1267 bool shouldDebugBreak() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1268 bool allowThrows() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1269
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1270 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1271 AssertionInfo m_assertionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1272 AssertionResultData m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1273 struct ExprComponents {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1274 ExprComponents() : testFalse( false ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1275 bool testFalse;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1276 std::string lhs, rhs, op;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1277 } m_exprComponents;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1278 CopyableStream m_stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1279
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1280 bool m_shouldDebugBreak;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1281 bool m_shouldThrow;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1282 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1283
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1284 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1285
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1286 // Include after due to circular dependency:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1287 // #included from: catch_expression_lhs.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1288 #define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1289
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1290 // #included from: catch_evaluate.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1291 #define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1292
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1293 #ifdef _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1294 #pragma warning(push)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1295 #pragma warning(disable:4389) // '==' : signed/unsigned mismatch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1296 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1297
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1298 #include <cstddef>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1299
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1300 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1301 namespace Internal {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1302
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1303 enum Operator {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1304 IsEqualTo,
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1305 IsNotEqualTo,
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1306 IsLessThan,
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1307 IsGreaterThan,
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1308 IsLessThanOrEqualTo,
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1309 IsGreaterThanOrEqualTo
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1310 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1311
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1312 template<Operator Op> struct OperatorTraits { static const char* getName(){ return "*error*"; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1313 template<> struct OperatorTraits<IsEqualTo> { static const char* getName(){ return "=="; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1314 template<> struct OperatorTraits<IsNotEqualTo> { static const char* getName(){ return "!="; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1315 template<> struct OperatorTraits<IsLessThan> { static const char* getName(){ return "<"; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1316 template<> struct OperatorTraits<IsGreaterThan> { static const char* getName(){ return ">"; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1317 template<> struct OperatorTraits<IsLessThanOrEqualTo> { static const char* getName(){ return "<="; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1318 template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1319
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1320 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1321 inline T& opCast(T const& t) { return const_cast<T&>(t); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1322
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1323 // nullptr_t support based on pull request #154 from Konstantin Baumann
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1324 #ifdef CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1325 inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1326 #endif // CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1327
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1328 // So the compare overloads can be operator agnostic we convey the operator as a template
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1329 // enum, which is used to specialise an Evaluator for doing the comparison.
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1330 template<typename T1, typename T2, Operator Op>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1331 class Evaluator{};
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1332
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1333 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1334 struct Evaluator<T1, T2, IsEqualTo> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1335 static bool evaluate( T1 const& lhs, T2 const& rhs) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1336 return bool( opCast( lhs ) == opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1337 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1338 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1339 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1340 struct Evaluator<T1, T2, IsNotEqualTo> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1341 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1342 return bool( opCast( lhs ) != opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1343 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1344 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1345 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1346 struct Evaluator<T1, T2, IsLessThan> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1347 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1348 return bool( opCast( lhs ) < opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1349 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1350 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1351 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1352 struct Evaluator<T1, T2, IsGreaterThan> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1353 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1354 return bool( opCast( lhs ) > opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1355 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1356 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1357 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1358 struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1359 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1360 return bool( opCast( lhs ) >= opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1361 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1362 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1363 template<typename T1, typename T2>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1364 struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1365 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1366 return bool( opCast( lhs ) <= opCast( rhs ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1367 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1368 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1369
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1370 template<Operator Op, typename T1, typename T2>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1371 bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1372 return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1373 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1374
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1375 // This level of indirection allows us to specialise for integer types
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1376 // to avoid signed/ unsigned warnings
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1377
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1378 // "base" overload
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1379 template<Operator Op, typename T1, typename T2>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1380 bool compare( T1 const& lhs, T2 const& rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1381 return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1382 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1383
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1384 // unsigned X to int
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1385 template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1386 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1387 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1388 template<Operator Op> bool compare( unsigned long lhs, int rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1389 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1390 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1391 template<Operator Op> bool compare( unsigned char lhs, int rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1392 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1393 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1394
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1395 // unsigned X to long
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1396 template<Operator Op> bool compare( unsigned int lhs, long rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1397 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1398 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1399 template<Operator Op> bool compare( unsigned long lhs, long rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1400 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1401 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1402 template<Operator Op> bool compare( unsigned char lhs, long rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1403 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1404 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1405
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1406 // int to unsigned X
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1407 template<Operator Op> bool compare( int lhs, unsigned int rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1408 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1409 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1410 template<Operator Op> bool compare( int lhs, unsigned long rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1411 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1412 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1413 template<Operator Op> bool compare( int lhs, unsigned char rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1414 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1415 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1416
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1417 // long to unsigned X
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1418 template<Operator Op> bool compare( long lhs, unsigned int rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1419 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1420 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1421 template<Operator Op> bool compare( long lhs, unsigned long rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1422 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1423 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1424 template<Operator Op> bool compare( long lhs, unsigned char rhs ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1425 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1426 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1427
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1428 // pointer to long (when comparing against NULL)
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1429 template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1430 return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1431 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1432 template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1433 return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1434 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1435
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1436 // pointer to int (when comparing against NULL)
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1437 template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1438 return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1439 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1440 template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1441 return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1442 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1443
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1444 #ifdef CATCH_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1445 // long long to unsigned X
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1446 template<Operator Op> bool compare( long long lhs, unsigned int rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1447 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1448 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1449 template<Operator Op> bool compare( long long lhs, unsigned long rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1450 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1451 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1452 template<Operator Op> bool compare( long long lhs, unsigned long long rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1453 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1454 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1455 template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1456 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1457 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1458
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1459 // unsigned long long to X
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1460 template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1461 return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1462 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1463 template<Operator Op> bool compare( unsigned long long lhs, long rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1464 return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1465 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1466 template<Operator Op> bool compare( unsigned long long lhs, long long rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1467 return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1468 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1469 template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1470 return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1471 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1472
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1473 // pointer to long long (when comparing against NULL)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1474 template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1475 return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1476 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1477 template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1478 return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1479 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1480 #endif // CATCH_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1481
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1482 #ifdef CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1483 // pointer to nullptr_t (when comparing against nullptr)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1484 template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1485 return Evaluator<T*, T*, Op>::evaluate( nullptr, rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1486 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1487 template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1488 return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1489 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1490 #endif // CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1491
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1492 } // end of namespace Internal
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1493 } // end of namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1494
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1495 #ifdef _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1496 #pragma warning(pop)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1497 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1498
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1499 // #included from: catch_tostring.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1500 #define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1501
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1502 #include <sstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1503 #include <iomanip>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1504 #include <limits>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1505 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1506 #include <cstddef>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1507
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1508 #ifdef __OBJC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1509 // #included from: catch_objc_arc.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1510 #define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1511
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1512 #import <Foundation/Foundation.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1513
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1514 #ifdef __has_feature
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1515 #define CATCH_ARC_ENABLED __has_feature(objc_arc)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1516 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1517 #define CATCH_ARC_ENABLED 0
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1518 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1519
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1520 void arcSafeRelease( NSObject* obj );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1521 id performOptionalSelector( id obj, SEL sel );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1522
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1523 #if !CATCH_ARC_ENABLED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1524 inline void arcSafeRelease( NSObject* obj ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1525 [obj release];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1526 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1527 inline id performOptionalSelector( id obj, SEL sel ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1528 if( [obj respondsToSelector: sel] )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1529 return [obj performSelector: sel];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1530 return nil;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1531 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1532 #define CATCH_UNSAFE_UNRETAINED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1533 #define CATCH_ARC_STRONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1534 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1535 inline void arcSafeRelease( NSObject* ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1536 inline id performOptionalSelector( id obj, SEL sel ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1537 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1538 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1539 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1540 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1541 if( [obj respondsToSelector: sel] )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1542 return [obj performSelector: sel];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1543 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1544 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1545 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1546 return nil;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1547 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1548 #define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1549 #define CATCH_ARC_STRONG __strong
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1550 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1551
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1552 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1553
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1554 #ifdef CATCH_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1555 #include <tuple>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1556 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1557
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1558 #ifdef CATCH_CONFIG_CPP11_IS_ENUM
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1559 #include <type_traits>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1560 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1561
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1562 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1563
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1564 // Why we're here.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1565 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1566 std::string toString( T const& value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1567
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1568 // Built in overloads
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1569
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1570 std::string toString( std::string const& value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1571 std::string toString( std::wstring const& value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1572 std::string toString( const char* const value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1573 std::string toString( char* const value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1574 std::string toString( const wchar_t* const value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1575 std::string toString( wchar_t* const value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1576 std::string toString( int value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1577 std::string toString( unsigned long value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1578 std::string toString( unsigned int value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1579 std::string toString( const double value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1580 std::string toString( const float value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1581 std::string toString( bool value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1582 std::string toString( char value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1583 std::string toString( signed char value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1584 std::string toString( unsigned char value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1585
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1586 #ifdef CATCH_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1587 std::string toString( long long value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1588 std::string toString( unsigned long long value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1589 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1590
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1591 #ifdef CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1592 std::string toString( std::nullptr_t );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1593 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1594
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1595 #ifdef __OBJC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1596 std::string toString( NSString const * const& nsstring );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1597 std::string toString( NSString * CATCH_ARC_STRONG const& nsstring );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1598 std::string toString( NSObject* const& nsObject );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1599 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1600
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1601 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1602
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1603 extern const std::string unprintableString;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1604
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1605 struct BorgType {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1606 template<typename T> BorgType( T const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1607 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1608
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1609 struct TrueType { char sizer[1]; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1610 struct FalseType { char sizer[2]; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1611
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1612 TrueType& testStreamable( std::ostream& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1613 FalseType testStreamable( FalseType );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1614
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1615 FalseType operator<<( std::ostream const&, BorgType const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1616
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1617 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1618 struct IsStreamInsertable {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1619 static std::ostream &s;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1620 static T const&t;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1621 enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1622 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1623
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1624 #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1625 template<typename T,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1626 bool IsEnum = std::is_enum<T>::value
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1627 >
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1628 struct EnumStringMaker
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1629 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1630 static std::string convert( T const& ) { return unprintableString; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1631 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1632
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1633 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1634 struct EnumStringMaker<T,true>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1635 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1636 static std::string convert( T const& v )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1637 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1638 return ::Catch::toString(
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1639 static_cast<typename std::underlying_type<T>::type>(v)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1640 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1641 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1642 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1643 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1644 template<bool C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1645 struct StringMakerBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1646 #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1647 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1648 static std::string convert( T const& v )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1649 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1650 return EnumStringMaker<T>::convert( v );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1651 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1652 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1653 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1654 static std::string convert( T const& ) { return unprintableString; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1655 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1656 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1657
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1658 template<>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1659 struct StringMakerBase<true> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1660 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1661 static std::string convert( T const& _value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1662 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1663 oss << _value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1664 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1665 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1666 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1667
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1668 std::string rawMemoryToString( const void *object, std::size_t size );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1669
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1670 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1671 inline std::string rawMemoryToString( const T& object ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1672 return rawMemoryToString( &object, sizeof(object) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1673 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1674
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1675 } // end namespace Detail
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1676
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1677 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1678 struct StringMaker :
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1679 Detail::StringMakerBase<Detail::IsStreamInsertable<T>::value> {};
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1680
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1681 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1682 struct StringMaker<T*> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1683 template<typename U>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1684 static std::string convert( U* p ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1685 if( !p )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1686 return "NULL";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1687 else
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1688 return Detail::rawMemoryToString( p );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1689 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1690 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1691
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1692 template<typename R, typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1693 struct StringMaker<R C::*> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1694 static std::string convert( R C::* p ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1695 if( !p )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1696 return "NULL";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1697 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1698 return Detail::rawMemoryToString( p );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1699 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1700 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1701
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1702 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1703 template<typename InputIterator>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1704 std::string rangeToString( InputIterator first, InputIterator last );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1705 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1706
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1707 //template<typename T, typename Allocator>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1708 //struct StringMaker<std::vector<T, Allocator> > {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1709 // static std::string convert( std::vector<T,Allocator> const& v ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1710 // return Detail::rangeToString( v.begin(), v.end() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1711 // }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1712 //};
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1713
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1714 template<typename T, typename Allocator>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1715 std::string toString( std::vector<T,Allocator> const& v ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1716 return Detail::rangeToString( v.begin(), v.end() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1717 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1718
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1719 #ifdef CATCH_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1720
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1721 // toString for tuples
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1722 namespace TupleDetail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1723 template<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1724 typename Tuple,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1725 std::size_t N = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1726 bool = (N < std::tuple_size<Tuple>::value)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1727 >
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1728 struct ElementPrinter {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1729 static void print( const Tuple& tuple, std::ostream& os )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1730 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1731 os << ( N ? ", " : " " )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1732 << Catch::toString(std::get<N>(tuple));
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1733 ElementPrinter<Tuple,N+1>::print(tuple,os);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1734 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1735 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1736
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1737 template<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1738 typename Tuple,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1739 std::size_t N
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1740 >
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1741 struct ElementPrinter<Tuple,N,false> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1742 static void print( const Tuple&, std::ostream& ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1743 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1744
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1745 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1746
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1747 template<typename ...Types>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1748 struct StringMaker<std::tuple<Types...>> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1749
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1750 static std::string convert( const std::tuple<Types...>& tuple )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1751 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1752 std::ostringstream os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1753 os << '{';
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1754 TupleDetail::ElementPrinter<std::tuple<Types...>>::print( tuple, os );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1755 os << " }";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1756 return os.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1757 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1758 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1759 #endif // CATCH_CONFIG_CPP11_TUPLE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1760
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1761 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1762 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1763 std::string makeString( T const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1764 return StringMaker<T>::convert( value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1765 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1766 } // end namespace Detail
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1767
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1768 /// \brief converts any type to a string
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1769 ///
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1770 /// The default template forwards on to ostringstream - except when an
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1771 /// ostringstream overload does not exist - in which case it attempts to detect
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1772 /// that and writes {?}.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1773 /// Overload (not specialise) this template for custom typs that you don't want
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1774 /// to provide an ostream overload for.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1775 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1776 std::string toString( T const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1777 return StringMaker<T>::convert( value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1778 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1779
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1780 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1781 template<typename InputIterator>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1782 std::string rangeToString( InputIterator first, InputIterator last ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1783 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1784 oss << "{ ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1785 if( first != last ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1786 oss << Catch::toString( *first );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1787 for( ++first ; first != last ; ++first )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1788 oss << ", " << Catch::toString( *first );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1789 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1790 oss << " }";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1791 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1792 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1793 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1794
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1795 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1796
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1797 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1798
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1799 // Wraps the LHS of an expression and captures the operator and RHS (if any) -
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1800 // wrapping them all in a ResultBuilder object
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1801 template<typename T>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1802 class ExpressionLhs {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1803 ExpressionLhs& operator = ( ExpressionLhs const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1804 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1805 ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1806 # endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1807
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1808 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1809 ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1810 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1811 ExpressionLhs( ExpressionLhs const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1812 ExpressionLhs( ExpressionLhs && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1813 # endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1814
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1815 template<typename RhsT>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1816 ResultBuilder& operator == ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1817 return captureExpression<Internal::IsEqualTo>( rhs );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1818 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1819
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1820 template<typename RhsT>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1821 ResultBuilder& operator != ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1822 return captureExpression<Internal::IsNotEqualTo>( rhs );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1823 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1824
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1825 template<typename RhsT>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1826 ResultBuilder& operator < ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1827 return captureExpression<Internal::IsLessThan>( rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1828 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1829
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1830 template<typename RhsT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1831 ResultBuilder& operator > ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1832 return captureExpression<Internal::IsGreaterThan>( rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1833 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1834
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1835 template<typename RhsT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1836 ResultBuilder& operator <= ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1837 return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1838 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1839
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1840 template<typename RhsT>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1841 ResultBuilder& operator >= ( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1842 return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1843 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1844
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1845 ResultBuilder& operator == ( bool rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1846 return captureExpression<Internal::IsEqualTo>( rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1847 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1848
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1849 ResultBuilder& operator != ( bool rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1850 return captureExpression<Internal::IsNotEqualTo>( rhs );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1851 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1852
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1853 void endExpression() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1854 bool value = m_lhs ? true : false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1855 m_rb
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1856 .setLhs( Catch::toString( value ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1857 .setResultType( value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1858 .endExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1859 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1860
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1861 // Only simple binary expressions are allowed on the LHS.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1862 // If more complex compositions are required then place the sub expression in parentheses
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1863 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1864 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1865 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1866 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1867 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1868 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1869
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1870 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1871 template<Internal::Operator Op, typename RhsT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1872 ResultBuilder& captureExpression( RhsT const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1873 return m_rb
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1874 .setResultType( Internal::compare<Op>( m_lhs, rhs ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1875 .setLhs( Catch::toString( m_lhs ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1876 .setRhs( Catch::toString( rhs ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1877 .setOp( Internal::OperatorTraits<Op>::getName() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1878 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1879
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1880 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1881 ResultBuilder& m_rb;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1882 T m_lhs;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1883 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1884
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1885 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1886
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1887
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1888 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1889
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1890 template<typename T>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1891 inline ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1892 return ExpressionLhs<T const&>( *this, operand );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1893 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1894
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1895 inline ExpressionLhs<bool> ResultBuilder::operator <= ( bool value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1896 return ExpressionLhs<bool>( *this, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1897 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1898
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1899 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1900
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1901 // #included from: catch_message.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1902 #define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1903
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1904 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1905
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1906 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1907
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1908 struct MessageInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1909 MessageInfo( std::string const& _macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1910 SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1911 ResultWas::OfType _type );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1912
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1913 std::string macroName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1914 SourceLineInfo lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1915 ResultWas::OfType type;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1916 std::string message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1917 unsigned int sequence;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1918
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1919 bool operator == ( MessageInfo const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1920 return sequence == other.sequence;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1921 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1922 bool operator < ( MessageInfo const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1923 return sequence < other.sequence;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1924 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1925 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1926 static unsigned int globalCount;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1927 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1928
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1929 struct MessageBuilder {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1930 MessageBuilder( std::string const& macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1931 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1932 ResultWas::OfType type )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1933 : m_info( macroName, lineInfo, type )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1934 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1935
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1936 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1937 MessageBuilder& operator << ( T const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1938 m_stream << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1939 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1940 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1941
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1942 MessageInfo m_info;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1943 std::ostringstream m_stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1944 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1945
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1946 class ScopedMessage {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1947 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1948 ScopedMessage( MessageBuilder const& builder );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1949 ScopedMessage( ScopedMessage const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1950 ~ScopedMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1951
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1952 MessageInfo m_info;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1953 };
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1954
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1955 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1956
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1957 // #included from: catch_interfaces_capture.h
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1958 #define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1959
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1960 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1961
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1962 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1963
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1964 class TestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1965 class AssertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1966 struct AssertionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1967 struct SectionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1968 struct SectionEndInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1969 struct MessageInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1970 class ScopedMessageBuilder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1971 struct Counts;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1972
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1973 struct IResultCapture {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1974
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1975 virtual ~IResultCapture();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1976
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1977 virtual void assertionEnded( AssertionResult const& result ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1978 virtual bool sectionStarted( SectionInfo const& sectionInfo,
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1979 Counts& assertions ) = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1980 virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1981 virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1982 virtual void pushScopedMessage( MessageInfo const& message ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1983 virtual void popScopedMessage( MessageInfo const& message ) = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1984
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1985 virtual std::string getCurrentTestName() const = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1986 virtual const AssertionResult* getLastResult() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1987
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1988 virtual void handleFatalErrorCondition( std::string const& message ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1989 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1990
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1991 IResultCapture& getResultCapture();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1992 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1993
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1994 // #included from: catch_debugger.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1995 #define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1996
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1997 // #included from: catch_platform.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
1998 #define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1999
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2000 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2001 #define CATCH_PLATFORM_MAC
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2002 #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2003 #define CATCH_PLATFORM_IPHONE
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2004 #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2005 #define CATCH_PLATFORM_WINDOWS
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2006 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2007
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2008 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2009
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2010 namespace Catch{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2011
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2012 bool isDebuggerActive();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2013 void writeToDebugConsole( std::string const& text );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2014 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2015
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2016 #ifdef CATCH_PLATFORM_MAC
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2017
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2018 // The following code snippet based on:
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2019 // http://cocoawithlove.com/2008/03/break-into-debugger.html
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2020 #ifdef DEBUG
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2021 #if defined(__ppc64__) || defined(__ppc__)
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2022 #define CATCH_BREAK_INTO_DEBUGGER() \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2023 if( Catch::isDebuggerActive() ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2024 __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2025 : : : "memory","r0","r3","r4" ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2026 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2027 #else
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2028 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2029 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2030 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2031
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2032 #elif defined(_MSC_VER)
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2033 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2034 #elif defined(__MINGW32__)
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2035 extern "C" __declspec(dllimport) void __stdcall DebugBreak();
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2036 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2037 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2039 #ifndef CATCH_BREAK_INTO_DEBUGGER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2040 #define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2041 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2042
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2043 // #included from: catch_interfaces_runner.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2044 #define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2045
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2046 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2047 class TestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2048
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2049 struct IRunner {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2050 virtual ~IRunner();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2051 virtual bool aborting() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2052 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2053 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2054
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2055 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2056 // In the event of a failure works out if the debugger needs to be invoked
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2057 // and/or an exception thrown and takes appropriate action.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2058 // This needs to be done as a macro so the debugger will stop in the user
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2059 // source code rather than in Catch library code
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2060 #define INTERNAL_CATCH_REACT( resultBuilder ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2061 if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2062 resultBuilder.react();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2063
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2064 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2065 #define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2066 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2067 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2068 try { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2069 CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2070 ( __catchResult <= expr ).endExpression(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2071 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2072 catch( ... ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2073 __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2074 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2075 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2076 } while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2077
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2078 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2079 #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2080 INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2081 if( Catch::getResultCapture().getLastResult()->succeeded() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2082
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2083 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2084 #define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2085 INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2086 if( !Catch::getResultCapture().getLastResult()->succeeded() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2087
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2088 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2089 #define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2090 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2091 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2092 try { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2093 expr; \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2094 __catchResult.captureResult( Catch::ResultWas::Ok ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2095 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2096 catch( ... ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2097 __catchResult.useActiveException( resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2098 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2099 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2100 } while( Catch::alwaysFalse() )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2101
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2102 ///////////////////////////////////////////////////////////////////////////////
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2103 #define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2104 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2105 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2106 if( __catchResult.allowThrows() ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2107 try { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2108 expr; \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2109 __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2110 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2111 catch( ... ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2112 __catchResult.captureExpectedException( matcher ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2113 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2114 else \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2115 __catchResult.captureResult( Catch::ResultWas::Ok ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2116 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2117 } while( Catch::alwaysFalse() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2118
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2119 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2120 #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2121 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2122 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2123 if( __catchResult.allowThrows() ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2124 try { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2125 expr; \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2126 __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2127 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2128 catch( exceptionType ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2129 __catchResult.captureResult( Catch::ResultWas::Ok ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2130 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2131 catch( ... ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2132 __catchResult.useActiveException( resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2133 } \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2134 else \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2135 __catchResult.captureResult( Catch::ResultWas::Ok ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2136 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2137 } while( Catch::alwaysFalse() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2138
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2139 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2140 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2141 #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2142 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2143 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2144 __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2145 __catchResult.captureResult( messageType ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2146 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2147 } while( Catch::alwaysFalse() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2148 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2149 #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2150 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2151 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2152 __catchResult << log + ::Catch::StreamEndStop(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2153 __catchResult.captureResult( messageType ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2154 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2155 } while( Catch::alwaysFalse() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2156 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2157
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2158 ///////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2159 #define INTERNAL_CATCH_INFO( log, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2160 Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2161
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2162 ///////////////////////////////////////////////////////////////////////////////
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2163 #define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2164 do { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2165 Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2166 try { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2167 std::string matcherAsString = (matcher).toString(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2168 __catchResult \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2169 .setLhs( Catch::toString( arg ) ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2170 .setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2171 .setOp( "matches" ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2172 .setResultType( (matcher).match( arg ) ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2173 __catchResult.captureExpression(); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2174 } catch( ... ) { \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2175 __catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2176 } \
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2177 INTERNAL_CATCH_REACT( __catchResult ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2178 } while( Catch::alwaysFalse() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2179
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2180 // #included from: internal/catch_section.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2181 #define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2182
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2183 // #included from: catch_section_info.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2184 #define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2185
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2186 // #included from: catch_totals.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2187 #define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2188
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2189 #include <cstddef>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2190
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2191 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2192
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2193 struct Counts {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2194 Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2195
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2196 Counts operator - ( Counts const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2197 Counts diff;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2198 diff.passed = passed - other.passed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2199 diff.failed = failed - other.failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2200 diff.failedButOk = failedButOk - other.failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2201 return diff;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2202 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2203 Counts& operator += ( Counts const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2204 passed += other.passed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2205 failed += other.failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2206 failedButOk += other.failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2207 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2208 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2209
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2210 std::size_t total() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2211 return passed + failed + failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2212 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2213 bool allPassed() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2214 return failed == 0 && failedButOk == 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2215 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2216 bool allOk() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2217 return failed == 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2218 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2219
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2220 std::size_t passed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2221 std::size_t failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2222 std::size_t failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2223 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2224
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2225 struct Totals {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2226
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2227 Totals operator - ( Totals const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2228 Totals diff;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2229 diff.assertions = assertions - other.assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2230 diff.testCases = testCases - other.testCases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2231 return diff;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2232 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2233
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2234 Totals delta( Totals const& prevTotals ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2235 Totals diff = *this - prevTotals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2236 if( diff.assertions.failed > 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2237 ++diff.testCases.failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2238 else if( diff.assertions.failedButOk > 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2239 ++diff.testCases.failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2240 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2241 ++diff.testCases.passed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2242 return diff;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2243 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2244
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2245 Totals& operator += ( Totals const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2246 assertions += other.assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2247 testCases += other.testCases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2248 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2249 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2250
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2251 Counts assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2252 Counts testCases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2253 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2254 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2255
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2256 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2257
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2258 struct SectionInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2259 SectionInfo
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2260 ( SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2261 std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2262 std::string const& _description = std::string() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2263
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2264 std::string name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2265 std::string description;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2266 SourceLineInfo lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2267 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2268
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2269 struct SectionEndInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2270 SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2271 : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2272 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2273
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2274 SectionInfo sectionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2275 Counts prevAssertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2276 double durationInSeconds;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2277 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2278
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2279 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2280
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2281 // #included from: catch_timer.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2282 #define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2283
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2284 #ifdef CATCH_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2285 typedef unsigned long long uint64_t;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2286 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2287 #include <stdint.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2288 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2289
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2290 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2291
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2292 class Timer {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2293 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2294 Timer() : m_ticks( 0 ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2295 void start();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2296 unsigned int getElapsedMicroseconds() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2297 unsigned int getElapsedMilliseconds() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2298 double getElapsedSeconds() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2299
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2300 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2301 uint64_t m_ticks;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2302 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2303
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2304 } // namespace Catch
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2305
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2306 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2307
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2308 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2309
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2310 class Section : NonCopyable {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2311 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2312 Section( SectionInfo const& info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2313 ~Section();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2314
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2315 // This indicates whether the section should be executed or not
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2316 operator bool() const;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2317
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2318 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2319 SectionInfo m_info;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2320
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2321 std::string m_name;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2322 Counts m_assertions;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2323 bool m_sectionIncluded;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2324 Timer m_timer;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2325 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2326
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2327 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2328
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2329 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2330 #define INTERNAL_CATCH_SECTION( ... ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2331 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2332 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2333 #define INTERNAL_CATCH_SECTION( name, desc ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2334 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2335 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2336
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2337 // #included from: internal/catch_generators.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2338 #define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2339
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2340 #include <iterator>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2341 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2342 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2343 #include <stdlib.h>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2344
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2345 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2346
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2347 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2348 struct IGenerator {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2349 virtual ~IGenerator() {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2350 virtual T getValue( std::size_t index ) const = 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2351 virtual std::size_t size () const = 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2352 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2353
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2354 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2355 class BetweenGenerator : public IGenerator<T> {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2356 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2357 BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2358
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2359 virtual T getValue( std::size_t index ) const {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2360 return m_from+static_cast<int>( index );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2361 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2362
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2363 virtual std::size_t size() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2364 return static_cast<std::size_t>( 1+m_to-m_from );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2365 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2366
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2367 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2368
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2369 T m_from;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2370 T m_to;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2371 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2372
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2373 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2374 class ValuesGenerator : public IGenerator<T> {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2375 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2376 ValuesGenerator(){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2377
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2378 void add( T value ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2379 m_values.push_back( value );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2380 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2381
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2382 virtual T getValue( std::size_t index ) const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2383 return m_values[index];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2384 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2385
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2386 virtual std::size_t size() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2387 return m_values.size();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2388 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2389
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2390 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2391 std::vector<T> m_values;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2392 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2393
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2394 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2395 class CompositeGenerator {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2396 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2397 CompositeGenerator() : m_totalSize( 0 ) {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2398
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2399 // *** Move semantics, similar to auto_ptr ***
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2400 CompositeGenerator( CompositeGenerator& other )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2401 : m_fileInfo( other.m_fileInfo ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2402 m_totalSize( 0 )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2403 {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2404 move( other );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2405 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2406
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2407 CompositeGenerator& setFileInfo( const char* fileInfo ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2408 m_fileInfo = fileInfo;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2409 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2410 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2411
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2412 ~CompositeGenerator() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2413 deleteAll( m_composed );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2414 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2415
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2416 operator T () const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2417 size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2418
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2419 typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2420 typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2421 for( size_t index = 0; it != itEnd; ++it )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2422 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2423 const IGenerator<T>* generator = *it;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2424 if( overallIndex >= index && overallIndex < index + generator->size() )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2425 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2426 return generator->getValue( overallIndex-index );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2427 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2428 index += generator->size();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2429 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2430 CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2431 return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2432 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2433
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2434 void add( const IGenerator<T>* generator ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2435 m_totalSize += generator->size();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2436 m_composed.push_back( generator );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2437 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2438
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2439 CompositeGenerator& then( CompositeGenerator& other ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2440 move( other );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2441 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2442 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2443
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2444 CompositeGenerator& then( T value ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2445 ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2446 valuesGen->add( value );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2447 add( valuesGen );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2448 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2449 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2450
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2451 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2452
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2453 void move( CompositeGenerator& other ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2454 std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2455 m_totalSize += other.m_totalSize;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2456 other.m_composed.clear();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2457 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2458
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2459 std::vector<const IGenerator<T>*> m_composed;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2460 std::string m_fileInfo;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2461 size_t m_totalSize;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2462 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2463
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2464 namespace Generators
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2465 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2466 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2467 CompositeGenerator<T> between( T from, T to ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2468 CompositeGenerator<T> generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2469 generators.add( new BetweenGenerator<T>( from, to ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2470 return generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2471 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2472
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2473 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2474 CompositeGenerator<T> values( T val1, T val2 ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2475 CompositeGenerator<T> generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2476 ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2477 valuesGen->add( val1 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2478 valuesGen->add( val2 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2479 generators.add( valuesGen );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2480 return generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2481 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2482
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2483 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2484 CompositeGenerator<T> values( T val1, T val2, T val3 ){
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2485 CompositeGenerator<T> generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2486 ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2487 valuesGen->add( val1 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2488 valuesGen->add( val2 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2489 valuesGen->add( val3 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2490 generators.add( valuesGen );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2491 return generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2492 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2493
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2494 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2495 CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2496 CompositeGenerator<T> generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2497 ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2498 valuesGen->add( val1 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2499 valuesGen->add( val2 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2500 valuesGen->add( val3 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2501 valuesGen->add( val4 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2502 generators.add( valuesGen );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2503 return generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2504 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2505
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2506 } // end namespace Generators
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2507
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2508 using namespace Generators;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2509
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2510 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2511
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2512 #define INTERNAL_CATCH_LINESTR2( line ) #line
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2513 #define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2514
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2515 #define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2516
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2517 // #included from: internal/catch_interfaces_exception.h
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2518 #define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2519
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2520 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2521 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2522
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2523 // #included from: catch_interfaces_registry_hub.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2524 #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2525
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2526 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2527
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2528 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2529
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2530 class TestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2531 struct ITestCaseRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2532 struct IExceptionTranslatorRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2533 struct IExceptionTranslator;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2534 struct IReporterRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2535 struct IReporterFactory;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2536
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2537 struct IRegistryHub {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2538 virtual ~IRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2539
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2540 virtual IReporterRegistry const& getReporterRegistry() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2541 virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2542 virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2543 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2544
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2545 struct IMutableRegistryHub {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2546 virtual ~IMutableRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2547 virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2548 virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2549 virtual void registerTest( TestCase const& testInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2550 virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2551 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2552
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2553 IRegistryHub& getRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2554 IMutableRegistryHub& getMutableRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2555 void cleanUp();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2556 std::string translateActiveException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2557
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2558 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2559
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2560 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2561
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2562 typedef std::string(*exceptionTranslateFunction)();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2563
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2564 struct IExceptionTranslator;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2565 typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2566
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2567 struct IExceptionTranslator {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2568 virtual ~IExceptionTranslator();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2569 virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2570 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2571
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2572 struct IExceptionTranslatorRegistry {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2573 virtual ~IExceptionTranslatorRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2574
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2575 virtual std::string translateActiveException() const = 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2576 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2577
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2578 class ExceptionTranslatorRegistrar {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2579 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2580 class ExceptionTranslator : public IExceptionTranslator {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2581 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2582
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2583 ExceptionTranslator( std::string(*translateFunction)( T& ) )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2584 : m_translateFunction( translateFunction )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2585 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2586
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2587 virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2588 try {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2589 if( it == itEnd )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2590 throw;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2591 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2592 return (*it)->translate( it+1, itEnd );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2593 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2594 catch( T& ex ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2595 return m_translateFunction( ex );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2596 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2597 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2598
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2599 protected:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2600 std::string(*m_translateFunction)( T& );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2601 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2602
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2603 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2604 template<typename T>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2605 ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2606 getMutableRegistryHub().registerTranslator
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2607 ( new ExceptionTranslator<T>( translateFunction ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2608 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2609 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2610 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2611
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2612 ///////////////////////////////////////////////////////////////////////////////
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2613 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2614 static std::string translatorName( signature ); \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2615 namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2616 static std::string translatorName( signature )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2617
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2618 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2619
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2620 // #included from: internal/catch_approx.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2621 #define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2622
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2623 #include <cmath>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2624 #include <limits>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2625
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2626 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2627 namespace Detail {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2628
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2629 class Approx {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2630 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2631 explicit Approx ( double value )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2632 : m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2633 m_scale( 1.0 ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2634 m_value( value )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2635 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2636
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2637 Approx( Approx const& other )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2638 : m_epsilon( other.m_epsilon ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2639 m_scale( other.m_scale ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2640 m_value( other.m_value )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2641 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2642
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2643 static Approx custom() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2644 return Approx( 0 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2645 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2646
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2647 Approx operator()( double value ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2648 Approx approx( value );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2649 approx.epsilon( m_epsilon );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2650 approx.scale( m_scale );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2651 return approx;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2652 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2653
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2654 friend bool operator == ( double lhs, Approx const& rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2655 // Thanks to Richard Harris for his help refining this formula
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2656 return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2657 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2658
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2659 friend bool operator == ( Approx const& lhs, double rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2660 return operator==( rhs, lhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2661 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2662
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2663 friend bool operator != ( double lhs, Approx const& rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2664 return !operator==( lhs, rhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2665 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2666
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2667 friend bool operator != ( Approx const& lhs, double rhs ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2668 return !operator==( rhs, lhs );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2669 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2670
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2671 Approx& epsilon( double newEpsilon ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2672 m_epsilon = newEpsilon;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2673 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2674 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2675
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2676 Approx& scale( double newScale ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2677 m_scale = newScale;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2678 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2679 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2680
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2681 std::string toString() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2682 std::ostringstream oss;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2683 oss << "Approx( " << Catch::toString( m_value ) << " )";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2684 return oss.str();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2685 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2686
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2687 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2688 double m_epsilon;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2689 double m_scale;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2690 double m_value;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2691 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2692 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2693
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2694 template<>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2695 inline std::string toString<Detail::Approx>( Detail::Approx const& value ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2696 return value.toString();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2697 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2698
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2699 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2700
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2701 // #included from: internal/catch_interfaces_tag_alias_registry.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2702 #define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2703
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2704 // #included from: catch_tag_alias.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2705 #define TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2706
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2707 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2708
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2709 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2710
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2711 struct TagAlias {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2712 TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2713
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2714 std::string tag;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2715 SourceLineInfo lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2716 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2717
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2718 struct RegistrarForTagAliases {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2719 RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2720 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2721
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2722 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2723
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2724 #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2725 // #included from: catch_option.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2726 #define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2727
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2728 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2729
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2730 // An optional type
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2731 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2732 class Option {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2733 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2734 Option() : nullableValue( CATCH_NULL ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2735 Option( T const& _value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2736 : nullableValue( new( storage ) T( _value ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2737 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2738 Option( Option const& _other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2739 : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2740 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2741
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2742 ~Option() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2743 reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2744 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2745
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2746 Option& operator= ( Option const& _other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2747 if( &_other != this ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2748 reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2749 if( _other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2750 nullableValue = new( storage ) T( *_other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2751 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2752 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2753 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2754 Option& operator = ( T const& _value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2755 reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2756 nullableValue = new( storage ) T( _value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2757 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2758 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2759
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2760 void reset() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2761 if( nullableValue )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2762 nullableValue->~T();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2763 nullableValue = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2764 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2765
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2766 T& operator*() { return *nullableValue; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2767 T const& operator*() const { return *nullableValue; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2768 T* operator->() { return nullableValue; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2769 const T* operator->() const { return nullableValue; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2770
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2771 T valueOr( T const& defaultValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2772 return nullableValue ? *nullableValue : defaultValue;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2773 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2774
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2775 bool some() const { return nullableValue != CATCH_NULL; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2776 bool none() const { return nullableValue == CATCH_NULL; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2777
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2778 bool operator !() const { return nullableValue == CATCH_NULL; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2779 operator SafeBool::type() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2780 return SafeBool::makeSafe( some() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2781 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2782
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2783 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2784 T* nullableValue;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2785 char storage[sizeof(T)];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2786 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2787
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2788 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2789
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2790 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2791
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2792 struct ITagAliasRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2793 virtual ~ITagAliasRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2794 virtual Option<TagAlias> find( std::string const& alias ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2795 virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2796
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2797 static ITagAliasRegistry const& get();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2798 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2799
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2800 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2801
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2802 // These files are included here so the single_include script doesn't put them
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2803 // in the conditionally compiled sections
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2804 // #included from: internal/catch_test_case_info.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2805 #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2807 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2808 #include <set>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2809
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2810 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2811 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2812 #pragma clang diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2813 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2814
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2815 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2816
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2817 struct ITestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2818
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2819 struct TestCaseInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2820 enum SpecialProperties{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2821 None = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2822 IsHidden = 1 << 1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2823 ShouldFail = 1 << 2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2824 MayFail = 1 << 3,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2825 Throws = 1 << 4
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2826 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2827
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2828 TestCaseInfo( std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2829 std::string const& _className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2830 std::string const& _description,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2831 std::set<std::string> const& _tags,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2832 SourceLineInfo const& _lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2833
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2834 TestCaseInfo( TestCaseInfo const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2835
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2836 friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2837
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2838 bool isHidden() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2839 bool throws() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2840 bool okToFail() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2841 bool expectedToFail() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2842
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2843 std::string name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2844 std::string className;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2845 std::string description;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2846 std::set<std::string> tags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2847 std::set<std::string> lcaseTags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2848 std::string tagsAsString;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2849 SourceLineInfo lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2850 SpecialProperties properties;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2851 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2852
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2853 class TestCase : public TestCaseInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2854 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2855
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2856 TestCase( ITestCase* testCase, TestCaseInfo const& info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2857 TestCase( TestCase const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2858
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2859 TestCase withName( std::string const& _newName ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2860
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2861 void invoke() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2862
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2863 TestCaseInfo const& getTestCaseInfo() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2864
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2865 void swap( TestCase& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2866 bool operator == ( TestCase const& other ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2867 bool operator < ( TestCase const& other ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2868 TestCase& operator = ( TestCase const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2869
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2870 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2871 Ptr<ITestCase> test;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2872 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2873
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2874 TestCase makeTestCase( ITestCase* testCase,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2875 std::string const& className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2876 std::string const& name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2877 std::string const& description,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2878 SourceLineInfo const& lineInfo );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2879 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2880
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2881 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2882 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2883 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2884
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2885
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2886 #ifdef __OBJC__
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2887 // #included from: internal/catch_objc.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2888 #define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2889
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2890 #import <objc/runtime.h>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2891
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2892 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2893
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2894 // NB. Any general catch headers included here must be included
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2895 // in catch.hpp first to make sure they are included by the single
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2896 // header for non obj-usage
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2897
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2898 ///////////////////////////////////////////////////////////////////////////////
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2899 // This protocol is really only here for (self) documenting purposes, since
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2900 // all its methods are optional.
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2901 @protocol OcFixture
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2902
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2903 @optional
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2904
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2905 -(void) setUp;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2906 -(void) tearDown;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2907
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2908 @end
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2909
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2910 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2911
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2912 class OcMethod : public SharedImpl<ITestCase> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2913
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2914 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2915 OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2916
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2917 virtual void invoke() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2918 id obj = [[m_cls alloc] init];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2919
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2920 performOptionalSelector( obj, @selector(setUp) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2921 performOptionalSelector( obj, m_sel );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2922 performOptionalSelector( obj, @selector(tearDown) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2923
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2924 arcSafeRelease( obj );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2925 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2926 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2927 virtual ~OcMethod() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2928
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2929 Class m_cls;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2930 SEL m_sel;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2931 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2932
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2933 namespace Detail{
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2934
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2935 inline std::string getAnnotation( Class cls,
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2936 std::string const& annotationName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2937 std::string const& testCaseName ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2938 NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2939 SEL sel = NSSelectorFromString( selStr );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2940 arcSafeRelease( selStr );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2941 id value = performOptionalSelector( cls, sel );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2942 if( value )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2943 return [(NSString*)value UTF8String];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2944 return "";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2945 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2946 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2947
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2948 inline size_t registerTestMethods() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2949 size_t noTestMethods = 0;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2950 int noClasses = objc_getClassList( CATCH_NULL, 0 );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2951
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2952 Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2953 objc_getClassList( classes, noClasses );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2954
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2955 for( int c = 0; c < noClasses; c++ ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2956 Class cls = classes[c];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2957 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2958 u_int count;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2959 Method* methods = class_copyMethodList( cls, &count );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2960 for( u_int m = 0; m < count ; m++ ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2961 SEL selector = method_getName(methods[m]);
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2962 std::string methodName = sel_getName(selector);
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2963 if( startsWith( methodName, "Catch_TestCase_" ) ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2964 std::string testCaseName = methodName.substr( 15 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2965 std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2966 std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2967 const char* className = class_getName( cls );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2968
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2969 getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2970 noTestMethods++;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2971 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2972 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2973 free(methods);
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2974 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2975 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2976 return noTestMethods;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2977 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2978
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2979 namespace Matchers {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2980 namespace Impl {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2981 namespace NSStringMatchers {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2982
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2983 template<typename MatcherT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2984 struct StringHolder : MatcherImpl<MatcherT, NSString*>{
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2985 StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2986 StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2987 StringHolder() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2988 arcSafeRelease( m_substr );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2989 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2990
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2991 NSString* m_substr;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2992 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2993
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2994 struct Equals : StringHolder<Equals> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2995 Equals( NSString* substr ) : StringHolder( substr ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2996
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2997 virtual bool match( ExpressionType const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2998 return (str != nil || m_substr == nil ) &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
2999 [str isEqualToString:m_substr];
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3000 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3001
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3002 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3003 return "equals string: " + Catch::toString( m_substr );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3004 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3005 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3006
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3007 struct Contains : StringHolder<Contains> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3008 Contains( NSString* substr ) : StringHolder( substr ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3009
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3010 virtual bool match( ExpressionType const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3011 return (str != nil || m_substr == nil ) &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3012 [str rangeOfString:m_substr].location != NSNotFound;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3013 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3014
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3015 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3016 return "contains string: " + Catch::toString( m_substr );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3017 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3018 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3019
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3020 struct StartsWith : StringHolder<StartsWith> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3021 StartsWith( NSString* substr ) : StringHolder( substr ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3022
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3023 virtual bool match( ExpressionType const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3024 return (str != nil || m_substr == nil ) &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3025 [str rangeOfString:m_substr].location == 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3026 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3027
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3028 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3029 return "starts with: " + Catch::toString( m_substr );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3030 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3031 };
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3032 struct EndsWith : StringHolder<EndsWith> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3033 EndsWith( NSString* substr ) : StringHolder( substr ){}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3034
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3035 virtual bool match( ExpressionType const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3036 return (str != nil || m_substr == nil ) &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3037 [str rangeOfString:m_substr].location == [str length] - [m_substr length];
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3038 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3039
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3040 virtual std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3041 return "ends with: " + Catch::toString( m_substr );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3042 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3043 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3044
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3045 } // namespace NSStringMatchers
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3046 } // namespace Impl
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3047
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3048 inline Impl::NSStringMatchers::Equals
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3049 Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3050
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3051 inline Impl::NSStringMatchers::Contains
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3052 Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3053
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3054 inline Impl::NSStringMatchers::StartsWith
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3055 StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3056
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3057 inline Impl::NSStringMatchers::EndsWith
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3058 EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3059
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3060 } // namespace Matchers
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3061
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3062 using namespace Matchers;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3063
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3064 } // namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3065
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3066 ///////////////////////////////////////////////////////////////////////////////
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3067 #define OC_TEST_CASE( name, desc )\
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3068 +(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3069 {\
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3070 return @ name; \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3071 }\
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3072 +(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3073 { \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3074 return @ desc; \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3075 } \
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3076 -(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3077
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3078 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3079
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3080 #ifdef CATCH_IMPL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3081 // #included from: internal/catch_impl.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3082 #define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3083
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3084 // Collect all the implementation files together here
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3085 // These are the equivalent of what would usually be cpp files
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3086
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3087 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3088 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3089 #pragma clang diagnostic ignored "-Wweak-vtables"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3090 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3091
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3092 // #included from: ../catch_session.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3093 #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3094
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3095 // #included from: internal/catch_commandline.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3096 #define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3097
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3098 // #included from: catch_config.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3099 #define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3100
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3101 // #included from: catch_test_spec_parser.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3102 #define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3103
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3104 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3105 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3106 #pragma clang diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3107 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3108
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3109 // #included from: catch_test_spec.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3110 #define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3111
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3112 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3113 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3114 #pragma clang diagnostic ignored "-Wpadded"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3115 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3116
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3117 // #included from: catch_wildcard_pattern.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3118 #define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3119
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3120 namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3121 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3122 class WildcardPattern {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3123 enum WildcardPosition {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3124 NoWildcard = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3125 WildcardAtStart = 1,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3126 WildcardAtEnd = 2,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3127 WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3128 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3129
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3130 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3131
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3132 WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3133 : m_caseSensitivity( caseSensitivity ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3134 m_wildcard( NoWildcard ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3135 m_pattern( adjustCase( pattern ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3136 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3137 if( startsWith( m_pattern, "*" ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3138 m_pattern = m_pattern.substr( 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3139 m_wildcard = WildcardAtStart;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3140 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3141 if( endsWith( m_pattern, "*" ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3142 m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3143 m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3144 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3145 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3146 virtual ~WildcardPattern();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3147 virtual bool matches( std::string const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3148 switch( m_wildcard ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3149 case NoWildcard:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3150 return m_pattern == adjustCase( str );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3151 case WildcardAtStart:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3152 return endsWith( adjustCase( str ), m_pattern );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3153 case WildcardAtEnd:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3154 return startsWith( adjustCase( str ), m_pattern );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3155 case WildcardAtBothEnds:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3156 return contains( adjustCase( str ), m_pattern );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3157 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3158
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3159 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3160 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3161 #pragma clang diagnostic ignored "-Wunreachable-code"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3162 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3163 throw std::logic_error( "Unknown enum" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3164 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3165 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3166 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3167 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3168 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3169 std::string adjustCase( std::string const& str ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3170 return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3171 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3172 CaseSensitive::Choice m_caseSensitivity;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3173 WildcardPosition m_wildcard;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3174 std::string m_pattern;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3175 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3176 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3177
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3178 #include <string>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3179 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3180
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3181 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3182
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3183 class TestSpec {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3184 struct Pattern : SharedImpl<> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3185 virtual ~Pattern();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3186 virtual bool matches( TestCaseInfo const& testCase ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3187 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3188 class NamePattern : public Pattern {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3189 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3190 NamePattern( std::string const& name )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3191 : m_wildcardPattern( toLower( name ), CaseSensitive::No )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3192 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3193 virtual ~NamePattern();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3194 virtual bool matches( TestCaseInfo const& testCase ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3195 return m_wildcardPattern.matches( toLower( testCase.name ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3196 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3197 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3198 WildcardPattern m_wildcardPattern;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3199 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3200
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3201 class TagPattern : public Pattern {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3202 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3203 TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3204 virtual ~TagPattern();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3205 virtual bool matches( TestCaseInfo const& testCase ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3206 return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3207 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3208 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3209 std::string m_tag;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3210 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3211
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3212 class ExcludedPattern : public Pattern {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3213 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3214 ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3215 virtual ~ExcludedPattern();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3216 virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3217 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3218 Ptr<Pattern> m_underlyingPattern;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3219 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3220
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3221 struct Filter {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3222 std::vector<Ptr<Pattern> > m_patterns;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3223
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3224 bool matches( TestCaseInfo const& testCase ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3225 // All patterns in a filter must match for the filter to be a match
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3226 for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3227 if( !(*it)->matches( testCase ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3228 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3229 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3230 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3231 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3232
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3233 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3234 bool hasFilters() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3235 return !m_filters.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3236 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3237 bool matches( TestCaseInfo const& testCase ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3238 // A TestSpec matches if any filter matches
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3239 for( std::vector<Filter>::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3240 if( it->matches( testCase ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3241 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3242 return false;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3243 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3244
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3245 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3246 std::vector<Filter> m_filters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3247
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3248 friend class TestSpecParser;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3249 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3250 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3251
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3252 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3253 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3254 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3255
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3256 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3257
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3258 class TestSpecParser {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3259 enum Mode{ None, Name, QuotedName, Tag };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3260 Mode m_mode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3261 bool m_exclusion;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3262 std::size_t m_start, m_pos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3263 std::string m_arg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3264 TestSpec::Filter m_currentFilter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3265 TestSpec m_testSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3266 ITagAliasRegistry const* m_tagAliases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3267
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3268 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3269 TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3270
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3271 TestSpecParser& parse( std::string const& arg ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3272 m_mode = None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3273 m_exclusion = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3274 m_start = std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3275 m_arg = m_tagAliases->expandAliases( arg );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3276 for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3277 visitChar( m_arg[m_pos] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3278 if( m_mode == Name )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3279 addPattern<TestSpec::NamePattern>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3280 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3281 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3282 TestSpec testSpec() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3283 addFilter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3284 return m_testSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3285 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3286 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3287 void visitChar( char c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3288 if( m_mode == None ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3289 switch( c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3290 case ' ': return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3291 case '~': m_exclusion = true; return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3292 case '[': return startNewMode( Tag, ++m_pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3293 case '"': return startNewMode( QuotedName, ++m_pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3294 default: startNewMode( Name, m_pos ); break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3295 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3296 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3297 if( m_mode == Name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3298 if( c == ',' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3299 addPattern<TestSpec::NamePattern>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3300 addFilter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3301 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3302 else if( c == '[' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3303 if( subString() == "exclude:" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3304 m_exclusion = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3305 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3306 addPattern<TestSpec::NamePattern>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3307 startNewMode( Tag, ++m_pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3308 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3309 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3310 else if( m_mode == QuotedName && c == '"' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3311 addPattern<TestSpec::NamePattern>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3312 else if( m_mode == Tag && c == ']' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3313 addPattern<TestSpec::TagPattern>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3314 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3315 void startNewMode( Mode mode, std::size_t start ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3316 m_mode = mode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3317 m_start = start;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3318 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3319 std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3320 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3321 void addPattern() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3322 std::string token = subString();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3323 if( startsWith( token, "exclude:" ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3324 m_exclusion = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3325 token = token.substr( 8 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3326 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3327 if( !token.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3328 Ptr<TestSpec::Pattern> pattern = new T( token );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3329 if( m_exclusion )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3330 pattern = new TestSpec::ExcludedPattern( pattern );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3331 m_currentFilter.m_patterns.push_back( pattern );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3332 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3333 m_exclusion = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3334 m_mode = None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3335 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3336 void addFilter() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3337 if( !m_currentFilter.m_patterns.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3338 m_testSpec.m_filters.push_back( m_currentFilter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3339 m_currentFilter = TestSpec::Filter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3340 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3341 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3342 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3343 inline TestSpec parseTestSpec( std::string const& arg ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3344 return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3345 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3346
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3347 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3348
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3349 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3350 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3351 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3352
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3353 // #included from: catch_interfaces_config.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3354 #define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3355
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3356 #include <iostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3357 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3358 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3359
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3360 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3361
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3362 struct Verbosity { enum Level {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3363 NoOutput = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3364 Quiet,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3365 Normal
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3366 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3367
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3368 struct WarnAbout { enum What {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3369 Nothing = 0x00,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3370 NoAssertions = 0x01
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3371 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3372
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3373 struct ShowDurations { enum OrNot {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3374 DefaultForReporter,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3375 Always,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3376 Never
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3377 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3378 struct RunTests { enum InWhatOrder {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3379 InDeclarationOrder,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3380 InLexicographicalOrder,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3381 InRandomOrder
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3382 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3383 struct UseColour { enum YesOrNo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3384 Auto,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3385 Yes,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3386 No
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3387 }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3388
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3389 class TestSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3390
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3391 struct IConfig : IShared {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3392
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3393 virtual ~IConfig();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3394
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3395 virtual bool allowThrows() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3396 virtual std::ostream& stream() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3397 virtual std::string name() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3398 virtual bool includeSuccessfulResults() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3399 virtual bool shouldDebugBreak() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3400 virtual bool warnAboutMissingAssertions() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3401 virtual int abortAfter() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3402 virtual bool showInvisibles() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3403 virtual ShowDurations::OrNot showDurations() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3404 virtual TestSpec const& testSpec() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3405 virtual RunTests::InWhatOrder runOrder() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3406 virtual unsigned int rngSeed() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3407 virtual UseColour::YesOrNo useColour() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3408 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3409 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3410
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3411 // #included from: catch_stream.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3412 #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3413
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3414 // #included from: catch_streambuf.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3415 #define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3416
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3417 #include <streambuf>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3418
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3419 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3420
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3421 class StreamBufBase : public std::streambuf {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3422 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3423 virtual ~StreamBufBase() CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3424 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3425 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3426
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3427 #include <streambuf>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3428 #include <ostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3429 #include <fstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3430
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3431 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3432
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3433 std::ostream& cout();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3434 std::ostream& cerr();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3435
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3436 struct IStream {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3437 virtual ~IStream() CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3438 virtual std::ostream& stream() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3439 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3440
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3441 class FileStream : public IStream {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3442 mutable std::ofstream m_ofs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3443 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3444 FileStream( std::string const& filename );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3445 virtual ~FileStream() CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3446 public: // IStream
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3447 virtual std::ostream& stream() const CATCH_OVERRIDE;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3448 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3449
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3450 class CoutStream : public IStream {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3451 mutable std::ostream m_os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3452 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3453 CoutStream();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3454 virtual ~CoutStream() CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3455
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3456 public: // IStream
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3457 virtual std::ostream& stream() const CATCH_OVERRIDE;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3458 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3459
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3460 class DebugOutStream : public IStream {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3461 CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3462 mutable std::ostream m_os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3463 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3464 DebugOutStream();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3465 virtual ~DebugOutStream() CATCH_NOEXCEPT;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3466
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3467 public: // IStream
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3468 virtual std::ostream& stream() const CATCH_OVERRIDE;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3469 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3470 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3471
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3472 #include <memory>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3473 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3474 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3475 #include <iostream>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3476 #include <ctime>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3477
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3478 #ifndef CATCH_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3479 #define CATCH_CONFIG_CONSOLE_WIDTH 80
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3480 #endif
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3481
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3482 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3483
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3484 struct ConfigData {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3485
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3486 ConfigData()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3487 : listTests( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3488 listTags( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3489 listReporters( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3490 listTestNamesOnly( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3491 showSuccessfulTests( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3492 shouldDebugBreak( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3493 noThrow( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3494 showHelp( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3495 showInvisibles( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3496 filenamesAsTags( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3497 abortAfter( -1 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3498 rngSeed( 0 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3499 verbosity( Verbosity::Normal ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3500 warnings( WarnAbout::Nothing ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3501 showDurations( ShowDurations::DefaultForReporter ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3502 runOrder( RunTests::InDeclarationOrder ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3503 useColour( UseColour::Auto )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3504 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3505
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3506 bool listTests;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3507 bool listTags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3508 bool listReporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3509 bool listTestNamesOnly;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3510
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3511 bool showSuccessfulTests;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3512 bool shouldDebugBreak;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3513 bool noThrow;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3514 bool showHelp;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3515 bool showInvisibles;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3516 bool filenamesAsTags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3517
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3518 int abortAfter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3519 unsigned int rngSeed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3520
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3521 Verbosity::Level verbosity;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3522 WarnAbout::What warnings;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3523 ShowDurations::OrNot showDurations;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3524 RunTests::InWhatOrder runOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3525 UseColour::YesOrNo useColour;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3526
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3527 std::string outputFilename;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3528 std::string name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3529 std::string processName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3530
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3531 std::vector<std::string> reporterNames;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3532 std::vector<std::string> testsOrTags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3533 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3534
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3535 class Config : public SharedImpl<IConfig> {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3536 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3537 Config( Config const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3538 Config& operator = ( Config const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3539 virtual void dummy();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3540 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3541
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3542 Config()
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3543 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3544
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3545 Config( ConfigData const& data )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3546 : m_data( data ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3547 m_stream( openStream() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3548 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3549 if( !data.testsOrTags.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3550 TestSpecParser parser( ITagAliasRegistry::get() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3551 for( std::size_t i = 0; i < data.testsOrTags.size(); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3552 parser.parse( data.testsOrTags[i] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3553 m_testSpec = parser.testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3554 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3555 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3556
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3557 virtual ~Config() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3558 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3559
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3560 std::string const& getFilename() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3561 return m_data.outputFilename ;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3562 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3563
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3564 bool listTests() const { return m_data.listTests; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3565 bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3566 bool listTags() const { return m_data.listTags; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3567 bool listReporters() const { return m_data.listReporters; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3568
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3569 std::string getProcessName() const { return m_data.processName; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3570
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3571 bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3572
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3573 std::vector<std::string> getReporterNames() const { return m_data.reporterNames; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3574
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3575 int abortAfter() const { return m_data.abortAfter; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3576
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3577 TestSpec const& testSpec() const { return m_testSpec; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3578
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3579 bool showHelp() const { return m_data.showHelp; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3580 bool showInvisibles() const { return m_data.showInvisibles; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3581
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3582 // IConfig interface
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3583 virtual bool allowThrows() const { return !m_data.noThrow; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3584 virtual std::ostream& stream() const { return m_stream->stream(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3585 virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3586 virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3587 virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3588 virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3589 virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3590 virtual unsigned int rngSeed() const { return m_data.rngSeed; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3591 virtual UseColour::YesOrNo useColour() const { return m_data.useColour; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3592
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3593 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3594
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3595 IStream const* openStream() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3596 if( m_data.outputFilename.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3597 return new CoutStream();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3598 else if( m_data.outputFilename[0] == '%' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3599 if( m_data.outputFilename == "%debug" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3600 return new DebugOutStream();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3601 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3602 throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3603 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3604 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3605 return new FileStream( m_data.outputFilename );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3606 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3607 ConfigData m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3608
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3609 CATCH_AUTO_PTR( IStream const ) m_stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3610 TestSpec m_testSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3611 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3612
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3613 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3614
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3615 // #included from: catch_clara.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3616 #define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3617
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3618 // Use Catch's value for console width (store Clara's off to the side, if present)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3619 #ifdef CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3620 #define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3621 #undef CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3622 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3623 #define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3624
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3625 // Declare Clara inside the Catch namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3626 #define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3627 // #included from: ../external/clara.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3628
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3629 // Version 0.0.2.4
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3630
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3631 // Only use header guard if we are not using an outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3632 #if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3633
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3634 #ifndef STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3635 #define TWOBLUECUBES_CLARA_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3636 #define STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3637 #define STITCH_CLARA_CLOSE_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3638 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3639 #define STITCH_CLARA_CLOSE_NAMESPACE }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3640 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3641
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3642 #define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3643
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3644 // ----------- #included from tbc_text_format.h -----------
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3645
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3646 // Only use header guard if we are not using an outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3647 #if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3648 #ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3649 #define TBC_TEXT_FORMAT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3650 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3651
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3652 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3653 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3654 #include <sstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3655 #include <algorithm>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3656
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3657 // Use optional outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3658 #ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3659 namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3660 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3661
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3662 namespace Tbc {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3663
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3664 #ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3665 const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3666 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3667 const unsigned int consoleWidth = 80;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3668 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3669
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3670 struct TextAttributes {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3671 TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3672 : initialIndent( std::string::npos ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3673 indent( 0 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3674 width( consoleWidth-1 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3675 tabChar( '\t' )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3676 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3677
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3678 TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3679 TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3680 TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3681 TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3682
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3683 std::size_t initialIndent; // indent of first line, or npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3684 std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3685 std::size_t width; // maximum width of text, including indent. Longer text will wrap
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3686 char tabChar; // If this char is seen the indent is changed to current pos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3687 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3688
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3689 class Text {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3690 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3691 Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3692 : attr( _attr )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3693 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3694 std::string wrappableChars = " [({.,/|\\-";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3695 std::size_t indent = _attr.initialIndent != std::string::npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3696 ? _attr.initialIndent
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3697 : _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3698 std::string remainder = _str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3699
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3700 while( !remainder.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3701 if( lines.size() >= 1000 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3702 lines.push_back( "... message truncated due to excessive size" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3703 return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3704 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3705 std::size_t tabPos = std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3706 std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3707 std::size_t pos = remainder.find_first_of( '\n' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3708 if( pos <= width ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3709 width = pos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3710 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3711 pos = remainder.find_last_of( _attr.tabChar, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3712 if( pos != std::string::npos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3713 tabPos = pos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3714 if( remainder[width] == '\n' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3715 width--;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3716 remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3717 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3718
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3719 if( width == remainder.size() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3720 spliceLine( indent, remainder, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3721 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3722 else if( remainder[width] == '\n' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3723 spliceLine( indent, remainder, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3724 if( width <= 1 || remainder.size() != 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3725 remainder = remainder.substr( 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3726 indent = _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3727 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3728 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3729 pos = remainder.find_last_of( wrappableChars, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3730 if( pos != std::string::npos && pos > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3731 spliceLine( indent, remainder, pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3732 if( remainder[0] == ' ' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3733 remainder = remainder.substr( 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3734 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3735 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3736 spliceLine( indent, remainder, width-1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3737 lines.back() += "-";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3738 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3739 if( lines.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3740 indent = _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3741 if( tabPos != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3742 indent += tabPos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3743 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3744 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3745 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3746
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3747 void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3748 lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3749 _remainder = _remainder.substr( _pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3750 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3751
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3752 typedef std::vector<std::string>::const_iterator const_iterator;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3753
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3754 const_iterator begin() const { return lines.begin(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3755 const_iterator end() const { return lines.end(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3756 std::string const& last() const { return lines.back(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3757 std::size_t size() const { return lines.size(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3758 std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3759 std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3760 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3761 oss << *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3762 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3763 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3764
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3765 inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3766 for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3767 it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3768 if( it != _text.begin() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3769 _stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3770 _stream << *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3771 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3772 return _stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3773 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3774
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3775 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3776 std::string str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3777 TextAttributes attr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3778 std::vector<std::string> lines;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3779 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3780
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3781 } // end namespace Tbc
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3782
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3783 #ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3784 } // end outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3785 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3786
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3787 #endif // TBC_TEXT_FORMAT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3788
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3789 // ----------- end of #include from tbc_text_format.h -----------
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3790 // ........... back in clara.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3791
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3792 #undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3793
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3794 // ----------- #included from clara_compilers.h -----------
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3795
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3796 #ifndef TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3797 #define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3798
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3799 // Detect a number of compiler features - mostly C++11/14 conformance - by compiler
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3800 // The following features are defined:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3801 //
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3802 // CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3803 // CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3804 // CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3805 // CLARA_CONFIG_CPP11_OVERRIDE : is override supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3806 // CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3807
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3808 // CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3809
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3810 // CLARA_CONFIG_VARIADIC_MACROS : are variadic macros supported?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3811
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3812 // In general each macro has a _NO_<feature name> form
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3813 // (e.g. CLARA_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3814 // Many features, at point of detection, define an _INTERNAL_ macro, so they
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3815 // can be combined, en-mass, with the _NO_ forms later.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3816
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3817 // All the C++11 features can be disabled with CLARA_CONFIG_NO_CPP11
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3818
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3819 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3820
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3821 #if __has_feature(cxx_nullptr)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3822 #define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3823 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3824
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3825 #if __has_feature(cxx_noexcept)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3826 #define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3827 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3828
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3829 #endif // __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3830
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3831 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3832 // GCC
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3833 #ifdef __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3834
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3835 #if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3836 #define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3837 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3838
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3839 // - otherwise more recent versions define __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3840 // and will get picked up below
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3841
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3842 #endif // __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3843
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3844 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3845 // Visual C++
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3846 #ifdef _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3847
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3848 #if (_MSC_VER >= 1600)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3849 #define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3850 #define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3851 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3852
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3853 #if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3854 #define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3855 #define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3856 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3857
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3858 #endif // _MSC_VER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3859
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3860 ////////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3861 // C++ language feature support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3862
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3863 // catch all support for C++11
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3864 #if defined(__cplusplus) && __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3865
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3866 #define CLARA_CPP11_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3867
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3868 #if !defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3869 #define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3870 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3871
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3872 #ifndef CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3873 #define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3874 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3875
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3876 #ifndef CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3877 #define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3878 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3879
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3880 #if !defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3881 #define CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3882 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3883 #if !defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3884 #define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3885 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3886
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3887 #endif // __cplusplus >= 201103L
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3888
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3889 // Now set the actual defines based on the above + anything the user has configured
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3890 #if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3891 #define CLARA_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3892 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3893 #if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3894 #define CLARA_CONFIG_CPP11_NOEXCEPT
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3895 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3896 #if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3897 #define CLARA_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3898 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3899 #if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3900 #define CLARA_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3901 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3902 #if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3903 #define CLARA_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3904 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3905
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3906 // noexcept support:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3907 #if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3908 #define CLARA_NOEXCEPT noexcept
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3909 # define CLARA_NOEXCEPT_IS(x) noexcept(x)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3910 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3911 #define CLARA_NOEXCEPT throw()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3912 # define CLARA_NOEXCEPT_IS(x)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3913 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3914
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3915 // nullptr support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3916 #ifdef CLARA_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3917 #define CLARA_NULL nullptr
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3918 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3919 #define CLARA_NULL NULL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3920 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3921
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3922 // override support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3923 #ifdef CLARA_CONFIG_CPP11_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3924 #define CLARA_OVERRIDE override
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3925 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3926 #define CLARA_OVERRIDE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3927 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3928
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3929 // unique_ptr support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3930 #ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3931 # define CLARA_AUTO_PTR( T ) std::unique_ptr<T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3932 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3933 # define CLARA_AUTO_PTR( T ) std::auto_ptr<T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3934 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3935
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3936 #endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3937
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3938 // ----------- end of #include from clara_compilers.h -----------
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3939 // ........... back in clara.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3940
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3941 #include <map>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3942 #include <stdexcept>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3943 #include <memory>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3944
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3945 #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3946 #define CLARA_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3947 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3948
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3949 // Use optional outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3950 #ifdef STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3951 STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3952 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3953
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3954 namespace Clara {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3955
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3956 struct UnpositionalTag {};
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3957
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3958 extern UnpositionalTag _;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3959
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3960 #ifdef CLARA_CONFIG_MAIN
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3961 UnpositionalTag _;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3962 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3963
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3964 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3965
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3966 #ifdef CLARA_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3967 const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3968 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3969 const unsigned int consoleWidth = 80;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3970 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3971
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3972 using namespace Tbc;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3973
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3974 inline bool startsWith( std::string const& str, std::string const& prefix ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3975 return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3976 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3977
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3978 template<typename T> struct RemoveConstRef{ typedef T type; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3979 template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3980 template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3981 template<typename T> struct RemoveConstRef<T const>{ typedef T type; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3982
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3983 template<typename T> struct IsBool { static const bool value = false; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3984 template<> struct IsBool<bool> { static const bool value = true; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3985
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3986 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3987 void convertInto( std::string const& _source, T& _dest ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3988 std::stringstream ss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3989 ss << _source;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3990 ss >> _dest;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3991 if( ss.fail() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3992 throw std::runtime_error( "Unable to convert " + _source + " to destination type" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3993 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3994 inline void convertInto( std::string const& _source, std::string& _dest ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3995 _dest = _source;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3996 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3997 inline void convertInto( std::string const& _source, bool& _dest ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3998 std::string sourceLC = _source;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
3999 std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4000 if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4001 _dest = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4002 else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4003 _dest = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4004 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4005 throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4006 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4007
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4008 template<typename ConfigT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4009 struct IArgFunction {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4010 virtual ~IArgFunction() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4011 #ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4012 IArgFunction() = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4013 IArgFunction( IArgFunction const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4014 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4015 virtual void set( ConfigT& config, std::string const& value ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4016 virtual bool takesArg() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4017 virtual IArgFunction* clone() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4018 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4019
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4020 template<typename ConfigT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4021 class BoundArgFunction {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4022 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4023 BoundArgFunction() : functionObj( CLARA_NULL ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4024 BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4025 BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4026 BoundArgFunction& operator = ( BoundArgFunction const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4027 IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4028 delete functionObj;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4029 functionObj = newFunctionObj;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4030 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4031 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4032 ~BoundArgFunction() { delete functionObj; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4033
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4034 void set( ConfigT& config, std::string const& value ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4035 functionObj->set( config, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4036 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4037 bool takesArg() const { return functionObj->takesArg(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4039 bool isSet() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4040 return functionObj != CLARA_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4041 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4042 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4043 IArgFunction<ConfigT>* functionObj;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4044 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4045
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4046 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4047 struct NullBinder : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4048 virtual void set( C&, std::string const& ) const {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4049 virtual bool takesArg() const { return true; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4050 virtual IArgFunction<C>* clone() const { return new NullBinder( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4051 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4052
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4053 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4054 struct BoundDataMember : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4055 BoundDataMember( M C::* _member ) : member( _member ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4056 virtual void set( C& p, std::string const& stringValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4057 convertInto( stringValue, p.*member );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4058 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4059 virtual bool takesArg() const { return !IsBool<M>::value; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4060 virtual IArgFunction<C>* clone() const { return new BoundDataMember( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4061 M C::* member;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4062 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4063 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4064 struct BoundUnaryMethod : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4065 BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4066 virtual void set( C& p, std::string const& stringValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4067 typename RemoveConstRef<M>::type value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4068 convertInto( stringValue, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4069 (p.*member)( value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4070 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4071 virtual bool takesArg() const { return !IsBool<M>::value; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4072 virtual IArgFunction<C>* clone() const { return new BoundUnaryMethod( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4073 void (C::*member)( M );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4074 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4075 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4076 struct BoundNullaryMethod : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4077 BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4078 virtual void set( C& p, std::string const& stringValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4079 bool value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4080 convertInto( stringValue, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4081 if( value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4082 (p.*member)();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4083 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4084 virtual bool takesArg() const { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4085 virtual IArgFunction<C>* clone() const { return new BoundNullaryMethod( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4086 void (C::*member)();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4087 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4088
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4089 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4090 struct BoundUnaryFunction : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4091 BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4092 virtual void set( C& obj, std::string const& stringValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4093 bool value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4094 convertInto( stringValue, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4095 if( value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4096 function( obj );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4097 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4098 virtual bool takesArg() const { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4099 virtual IArgFunction<C>* clone() const { return new BoundUnaryFunction( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4100 void (*function)( C& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4101 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4102
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4103 template<typename C, typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4104 struct BoundBinaryFunction : IArgFunction<C>{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4105 BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4106 virtual void set( C& obj, std::string const& stringValue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4107 typename RemoveConstRef<T>::type value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4108 convertInto( stringValue, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4109 function( obj, value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4110 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4111 virtual bool takesArg() const { return !IsBool<T>::value; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4112 virtual IArgFunction<C>* clone() const { return new BoundBinaryFunction( *this ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4113 void (*function)( C&, T );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4114 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4115
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4116 } // namespace Detail
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4117
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4118 inline std::vector<std::string> argsToVector( int argc, char const* const* const argv ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4119 std::vector<std::string> args( static_cast<std::size_t>( argc ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4120 for( std::size_t i = 0; i < static_cast<std::size_t>( argc ); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4121 args[i] = argv[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4122
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4123 return args;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4124 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4125
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4126 class Parser {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4127 enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4128 Mode mode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4129 std::size_t from;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4130 bool inQuotes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4131 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4132
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4133 struct Token {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4134 enum Type { Positional, ShortOpt, LongOpt };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4135 Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4136 Type type;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4137 std::string data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4138 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4139
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4140 Parser() : mode( None ), from( 0 ), inQuotes( false ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4141
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4142 void parseIntoTokens( std::vector<std::string> const& args, std::vector<Token>& tokens ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4143 const std::string doubleDash = "--";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4144 for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4145 parseIntoTokens( args[i], tokens);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4146 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4147
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4148 void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4149 for( std::size_t i = 0; i <= arg.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4150 char c = arg[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4151 if( c == '"' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4152 inQuotes = !inQuotes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4153 mode = handleMode( i, c, arg, tokens );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4154 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4155 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4156 Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4157 switch( mode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4158 case None: return handleNone( i, c );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4159 case MaybeShortOpt: return handleMaybeShortOpt( i, c );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4160 case ShortOpt:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4161 case LongOpt:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4162 case SlashOpt: return handleOpt( i, c, arg, tokens );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4163 case Positional: return handlePositional( i, c, arg, tokens );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4164 default: throw std::logic_error( "Unknown mode" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4165 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4166 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4167
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4168 Mode handleNone( std::size_t i, char c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4169 if( inQuotes ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4170 from = i;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4171 return Positional;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4172 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4173 switch( c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4174 case '-': return MaybeShortOpt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4175 #ifdef CLARA_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4176 case '/': from = i+1; return SlashOpt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4177 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4178 default: from = i; return Positional;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4179 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4180 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4181 Mode handleMaybeShortOpt( std::size_t i, char c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4182 switch( c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4183 case '-': from = i+1; return LongOpt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4184 default: from = i; return ShortOpt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4185 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4186 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4187 Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4188 if( std::string( ":=\0", 3 ).find( c ) == std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4189 return mode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4190
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4191 std::string optName = arg.substr( from, i-from );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4192 if( mode == ShortOpt )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4193 for( std::size_t j = 0; j < optName.size(); ++j )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4194 tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4195 else if( mode == SlashOpt && optName.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4196 tokens.push_back( Token( Token::ShortOpt, optName ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4197 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4198 tokens.push_back( Token( Token::LongOpt, optName ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4199 return None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4200 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4201 Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4202 if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4203 return mode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4204
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4205 std::string data = arg.substr( from, i-from );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4206 tokens.push_back( Token( Token::Positional, data ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4207 return None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4208 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4209 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4210
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4211 template<typename ConfigT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4212 struct CommonArgProperties {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4213 CommonArgProperties() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4214 CommonArgProperties( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4215
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4216 Detail::BoundArgFunction<ConfigT> boundField;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4217 std::string description;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4218 std::string detail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4219 std::string placeholder; // Only value if boundField takes an arg
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4220
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4221 bool takesArg() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4222 return !placeholder.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4223 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4224 void validate() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4225 if( !boundField.isSet() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4226 throw std::logic_error( "option not bound" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4227 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4228 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4229 struct OptionArgProperties {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4230 std::vector<std::string> shortNames;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4231 std::string longName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4232
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4233 bool hasShortName( std::string const& shortName ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4234 return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4235 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4236 bool hasLongName( std::string const& _longName ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4237 return _longName == longName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4238 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4239 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4240 struct PositionalArgProperties {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4241 PositionalArgProperties() : position( -1 ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4242 int position; // -1 means non-positional (floating)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4243
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4244 bool isFixedPositional() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4245 return position != -1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4246 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4247 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4248
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4249 template<typename ConfigT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4250 class CommandLine {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4251
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4252 struct Arg : CommonArgProperties<ConfigT>, OptionArgProperties, PositionalArgProperties {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4253 Arg() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4254 Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : CommonArgProperties<ConfigT>( _boundField ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4255
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4256 using CommonArgProperties<ConfigT>::placeholder; // !TBD
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4257
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4258 std::string dbgName() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4259 if( !longName.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4260 return "--" + longName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4261 if( !shortNames.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4262 return "-" + shortNames[0];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4263 return "positional args";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4264 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4265 std::string commands() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4266 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4267 bool first = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4268 std::vector<std::string>::const_iterator it = shortNames.begin(), itEnd = shortNames.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4269 for(; it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4270 if( first )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4271 first = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4272 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4273 oss << ", ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4274 oss << "-" << *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4275 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4276 if( !longName.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4277 if( !first )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4278 oss << ", ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4279 oss << "--" << longName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4280 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4281 if( !placeholder.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4282 oss << " <" << placeholder << ">";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4283 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4284 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4285 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4286
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4287 typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4288
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4289 friend void addOptName( Arg& arg, std::string const& optName )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4290 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4291 if( optName.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4292 return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4293 if( Detail::startsWith( optName, "--" ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4294 if( !arg.longName.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4295 throw std::logic_error( "Only one long opt may be specified. '"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4296 + arg.longName
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4297 + "' already specified, now attempting to add '"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4298 + optName + "'" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4299 arg.longName = optName.substr( 2 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4300 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4301 else if( Detail::startsWith( optName, "-" ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4302 arg.shortNames.push_back( optName.substr( 1 ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4303 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4304 throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4305 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4306 friend void setPositionalArg( Arg& arg, int position )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4307 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4308 arg.position = position;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4309 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4310
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4311 class ArgBuilder {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4312 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4313 ArgBuilder( Arg* arg ) : m_arg( arg ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4314
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4315 // Bind a non-boolean data member (requires placeholder string)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4316 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4317 void bind( M C::* field, std::string const& placeholder ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4318 m_arg->boundField = new Detail::BoundDataMember<C,M>( field );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4319 m_arg->placeholder = placeholder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4320 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4321 // Bind a boolean data member (no placeholder required)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4322 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4323 void bind( bool C::* field ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4324 m_arg->boundField = new Detail::BoundDataMember<C,bool>( field );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4325 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4326
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4327 // Bind a method taking a single, non-boolean argument (requires a placeholder string)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4328 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4329 void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4330 m_arg->boundField = new Detail::BoundUnaryMethod<C,M>( unaryMethod );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4331 m_arg->placeholder = placeholder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4332 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4333
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4334 // Bind a method taking a single, boolean argument (no placeholder string required)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4335 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4336 void bind( void (C::* unaryMethod)( bool ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4337 m_arg->boundField = new Detail::BoundUnaryMethod<C,bool>( unaryMethod );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4338 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4339
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4340 // Bind a method that takes no arguments (will be called if opt is present)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4341 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4342 void bind( void (C::* nullaryMethod)() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4343 m_arg->boundField = new Detail::BoundNullaryMethod<C>( nullaryMethod );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4344 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4345
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4346 // Bind a free function taking a single argument - the object to operate on (no placeholder string required)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4347 template<typename C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4348 void bind( void (* unaryFunction)( C& ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4349 m_arg->boundField = new Detail::BoundUnaryFunction<C>( unaryFunction );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4350 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4351
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4352 // Bind a free function taking a single argument - the object to operate on (requires a placeholder string)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4353 template<typename C, typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4354 void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4355 m_arg->boundField = new Detail::BoundBinaryFunction<C, T>( binaryFunction );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4356 m_arg->placeholder = placeholder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4357 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4358
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4359 ArgBuilder& describe( std::string const& description ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4360 m_arg->description = description;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4361 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4362 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4363 ArgBuilder& detail( std::string const& detail ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4364 m_arg->detail = detail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4365 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4366 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4367
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4368 protected:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4369 Arg* m_arg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4370 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4371
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4372 class OptBuilder : public ArgBuilder {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4373 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4374 OptBuilder( Arg* arg ) : ArgBuilder( arg ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4375 OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4376
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4377 OptBuilder& operator[]( std::string const& optName ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4378 addOptName( *ArgBuilder::m_arg, optName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4379 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4380 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4381 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4382
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4383 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4384
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4385 CommandLine()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4386 : m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4387 m_highestSpecifiedArgPosition( 0 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4388 m_throwOnUnrecognisedTokens( false )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4389 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4390 CommandLine( CommandLine const& other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4391 : m_boundProcessName( other.m_boundProcessName ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4392 m_options ( other.m_options ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4393 m_positionalArgs( other.m_positionalArgs ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4394 m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4395 m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4396 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4397 if( other.m_floatingArg.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4398 m_floatingArg.reset( new Arg( *other.m_floatingArg ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4399 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4400
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4401 CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4402 m_throwOnUnrecognisedTokens = shouldThrow;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4403 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4404 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4405
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4406 OptBuilder operator[]( std::string const& optName ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4407 m_options.push_back( Arg() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4408 addOptName( m_options.back(), optName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4409 OptBuilder builder( &m_options.back() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4410 return builder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4411 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4412
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4413 ArgBuilder operator[]( int position ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4414 m_positionalArgs.insert( std::make_pair( position, Arg() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4415 if( position > m_highestSpecifiedArgPosition )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4416 m_highestSpecifiedArgPosition = position;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4417 setPositionalArg( m_positionalArgs[position], position );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4418 ArgBuilder builder( &m_positionalArgs[position] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4419 return builder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4420 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4421
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4422 // Invoke this with the _ instance
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4423 ArgBuilder operator[]( UnpositionalTag ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4424 if( m_floatingArg.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4425 throw std::logic_error( "Only one unpositional argument can be added" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4426 m_floatingArg.reset( new Arg() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4427 ArgBuilder builder( m_floatingArg.get() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4428 return builder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4429 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4430
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4431 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4432 void bindProcessName( M C::* field ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4433 m_boundProcessName = new Detail::BoundDataMember<C,M>( field );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4434 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4435 template<typename C, typename M>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4436 void bindProcessName( void (C::*_unaryMethod)( M ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4437 m_boundProcessName = new Detail::BoundUnaryMethod<C,M>( _unaryMethod );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4438 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4439
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4440 void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4441 typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4442 std::size_t maxWidth = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4443 for( it = itBegin; it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4444 maxWidth = (std::max)( maxWidth, it->commands().size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4445
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4446 for( it = itBegin; it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4447 Detail::Text usage( it->commands(), Detail::TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4448 .setWidth( maxWidth+indent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4449 .setIndent( indent ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4450 Detail::Text desc( it->description, Detail::TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4451 .setWidth( width - maxWidth - 3 ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4452
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4453 for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4454 std::string usageCol = i < usage.size() ? usage[i] : "";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4455 os << usageCol;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4456
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4457 if( i < desc.size() && !desc[i].empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4458 os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4459 << desc[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4460 os << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4461 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4462 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4463 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4464 std::string optUsage() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4465 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4466 optUsage( oss );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4467 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4468 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4469
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4470 void argSynopsis( std::ostream& os ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4471 for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4472 if( i > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4473 os << " ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4474 typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4475 if( it != m_positionalArgs.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4476 os << "<" << it->second.placeholder << ">";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4477 else if( m_floatingArg.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4478 os << "<" << m_floatingArg->placeholder << ">";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4479 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4480 throw std::logic_error( "non consecutive positional arguments with no floating args" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4481 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4482 // !TBD No indication of mandatory args
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4483 if( m_floatingArg.get() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4484 if( m_highestSpecifiedArgPosition > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4485 os << " ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4486 os << "[<" << m_floatingArg->placeholder << "> ...]";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4487 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4488 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4489 std::string argSynopsis() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4490 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4491 argSynopsis( oss );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4492 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4493 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4494
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4495 void usage( std::ostream& os, std::string const& procName ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4496 validate();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4497 os << "usage:\n " << procName << " ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4498 argSynopsis( os );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4499 if( !m_options.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4500 os << " [options]\n\nwhere options are: \n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4501 optUsage( os, 2 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4502 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4503 os << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4504 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4505 std::string usage( std::string const& procName ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4506 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4507 usage( oss, procName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4508 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4509 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4510
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4511 ConfigT parse( std::vector<std::string> const& args ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4512 ConfigT config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4513 parseInto( args, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4514 return config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4515 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4516
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4517 std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4518 std::string processName = args[0];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4519 std::size_t lastSlash = processName.find_last_of( "/\\" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4520 if( lastSlash != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4521 processName = processName.substr( lastSlash+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4522 m_boundProcessName.set( config, processName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4523 std::vector<Parser::Token> tokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4524 Parser parser;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4525 parser.parseIntoTokens( args, tokens );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4526 return populate( tokens, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4527 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4528
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4529 std::vector<Parser::Token> populate( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4530 validate();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4531 std::vector<Parser::Token> unusedTokens = populateOptions( tokens, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4532 unusedTokens = populateFixedArgs( unusedTokens, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4533 unusedTokens = populateFloatingArgs( unusedTokens, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4534 return unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4535 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4536
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4537 std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4538 std::vector<Parser::Token> unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4539 std::vector<std::string> errors;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4540 for( std::size_t i = 0; i < tokens.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4541 Parser::Token const& token = tokens[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4542 typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4543 for(; it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4544 Arg const& arg = *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4545
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4546 try {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4547 if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) ||
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4548 ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4549 if( arg.takesArg() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4550 if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4551 errors.push_back( "Expected argument to option: " + token.data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4552 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4553 arg.boundField.set( config, tokens[++i].data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4554 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4555 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4556 arg.boundField.set( config, "true" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4557 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4558 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4559 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4560 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4561 catch( std::exception& ex ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4562 errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4563 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4564 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4565 if( it == itEnd ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4566 if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4567 unusedTokens.push_back( token );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4568 else if( errors.empty() && m_throwOnUnrecognisedTokens )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4569 errors.push_back( "unrecognised option: " + token.data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4570 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4571 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4572 if( !errors.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4573 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4574 for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4575 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4576 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4577 if( it != errors.begin() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4578 oss << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4579 oss << *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4580 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4581 throw std::runtime_error( oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4582 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4583 return unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4584 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4585 std::vector<Parser::Token> populateFixedArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4586 std::vector<Parser::Token> unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4587 int position = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4588 for( std::size_t i = 0; i < tokens.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4589 Parser::Token const& token = tokens[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4590 typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( position );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4591 if( it != m_positionalArgs.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4592 it->second.boundField.set( config, token.data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4593 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4594 unusedTokens.push_back( token );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4595 if( token.type == Parser::Token::Positional )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4596 position++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4597 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4598 return unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4599 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4600 std::vector<Parser::Token> populateFloatingArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4601 if( !m_floatingArg.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4602 return tokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4603 std::vector<Parser::Token> unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4604 for( std::size_t i = 0; i < tokens.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4605 Parser::Token const& token = tokens[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4606 if( token.type == Parser::Token::Positional )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4607 m_floatingArg->boundField.set( config, token.data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4608 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4609 unusedTokens.push_back( token );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4610 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4611 return unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4612 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4613
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4614 void validate() const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4615 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4616 if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4617 throw std::logic_error( "No options or arguments specified" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4618
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4619 for( typename std::vector<Arg>::const_iterator it = m_options.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4620 itEnd = m_options.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4621 it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4622 it->validate();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4623 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4624
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4625 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4626 Detail::BoundArgFunction<ConfigT> m_boundProcessName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4627 std::vector<Arg> m_options;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4628 std::map<int, Arg> m_positionalArgs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4629 ArgAutoPtr m_floatingArg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4630 int m_highestSpecifiedArgPosition;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4631 bool m_throwOnUnrecognisedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4632 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4633
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4634 } // end namespace Clara
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4635
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4636 STITCH_CLARA_CLOSE_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4637 #undef STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4638 #undef STITCH_CLARA_CLOSE_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4639
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4640 #endif // TWOBLUECUBES_CLARA_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4641 #undef STITCH_CLARA_OPEN_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4642
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4643 // Restore Clara's value for console width, if present
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4644 #ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4645 #define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4646 #undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4647 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4648
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4649 #include <fstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4650
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4651 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4652
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4653 inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4654 inline void abortAfterX( ConfigData& config, int x ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4655 if( x < 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4656 throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4657 config.abortAfter = x;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4658 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4659 inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4660 inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4661
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4662 inline void addWarning( ConfigData& config, std::string const& _warning ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4663 if( _warning == "NoAssertions" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4664 config.warnings = static_cast<WarnAbout::What>( config.warnings | WarnAbout::NoAssertions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4665 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4666 throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4667 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4668 inline void setOrder( ConfigData& config, std::string const& order ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4669 if( startsWith( "declared", order ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4670 config.runOrder = RunTests::InDeclarationOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4671 else if( startsWith( "lexical", order ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4672 config.runOrder = RunTests::InLexicographicalOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4673 else if( startsWith( "random", order ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4674 config.runOrder = RunTests::InRandomOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4675 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4676 throw std::runtime_error( "Unrecognised ordering: '" + order + "'" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4677 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4678 inline void setRngSeed( ConfigData& config, std::string const& seed ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4679 if( seed == "time" ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4680 config.rngSeed = static_cast<unsigned int>( std::time(0) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4681 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4682 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4683 std::stringstream ss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4684 ss << seed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4685 ss >> config.rngSeed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4686 if( ss.fail() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4687 throw std::runtime_error( "Argment to --rng-seed should be the word 'time' or a number" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4688 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4689 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4690 inline void setVerbosity( ConfigData& config, int level ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4691 // !TBD: accept strings?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4692 config.verbosity = static_cast<Verbosity::Level>( level );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4693 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4694 inline void setShowDurations( ConfigData& config, bool _showDurations ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4695 config.showDurations = _showDurations
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4696 ? ShowDurations::Always
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4697 : ShowDurations::Never;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4698 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4699 inline void setUseColour( ConfigData& config, std::string const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4700 std::string mode = toLower( value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4701
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4702 if( mode == "yes" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4703 config.useColour = UseColour::Yes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4704 else if( mode == "no" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4705 config.useColour = UseColour::No;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4706 else if( mode == "auto" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4707 config.useColour = UseColour::Auto;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4708 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4709 throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4710 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4711 inline void forceColour( ConfigData& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4712 config.useColour = UseColour::Yes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4713 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4714 inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4715 std::ifstream f( _filename.c_str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4716 if( !f.is_open() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4717 throw std::domain_error( "Unable to load input file: " + _filename );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4718
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4719 std::string line;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4720 while( std::getline( f, line ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4721 line = trim(line);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4722 if( !line.empty() && !startsWith( line, "#" ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4723 addTestOrTags( config, "\"" + line + "\"," );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4724 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4725 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4726
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4727 inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4728
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4729 using namespace Clara;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4730 CommandLine<ConfigData> cli;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4731
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4732 cli.bindProcessName( &ConfigData::processName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4733
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4734 cli["-?"]["-h"]["--help"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4735 .describe( "display usage information" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4736 .bind( &ConfigData::showHelp );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4737
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4738 cli["-l"]["--list-tests"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4739 .describe( "list all/matching test cases" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4740 .bind( &ConfigData::listTests );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4741
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4742 cli["-t"]["--list-tags"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4743 .describe( "list all/matching tags" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4744 .bind( &ConfigData::listTags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4745
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4746 cli["-s"]["--success"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4747 .describe( "include successful tests in output" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4748 .bind( &ConfigData::showSuccessfulTests );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4749
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4750 cli["-b"]["--break"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4751 .describe( "break into debugger on failure" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4752 .bind( &ConfigData::shouldDebugBreak );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4753
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4754 cli["-e"]["--nothrow"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4755 .describe( "skip exception tests" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4756 .bind( &ConfigData::noThrow );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4757
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4758 cli["-i"]["--invisibles"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4759 .describe( "show invisibles (tabs, newlines)" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4760 .bind( &ConfigData::showInvisibles );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4761
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4762 cli["-o"]["--out"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4763 .describe( "output filename" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4764 .bind( &ConfigData::outputFilename, "filename" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4765
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4766 cli["-r"]["--reporter"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4767 // .placeholder( "name[:filename]" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4768 .describe( "reporter to use (defaults to console)" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4769 .bind( &addReporterName, "name" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4770
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4771 cli["-n"]["--name"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4772 .describe( "suite name" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4773 .bind( &ConfigData::name, "name" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4774
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4775 cli["-a"]["--abort"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4776 .describe( "abort at first failure" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4777 .bind( &abortAfterFirst );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4778
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4779 cli["-x"]["--abortx"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4780 .describe( "abort after x failures" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4781 .bind( &abortAfterX, "no. failures" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4782
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4783 cli["-w"]["--warn"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4784 .describe( "enable warnings" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4785 .bind( &addWarning, "warning name" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4786
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4787 // - needs updating if reinstated
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4788 // cli.into( &setVerbosity )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4789 // .describe( "level of verbosity (0=no output)" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4790 // .shortOpt( "v")
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4791 // .longOpt( "verbosity" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4792 // .placeholder( "level" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4793
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4794 cli[_]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4795 .describe( "which test or tests to use" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4796 .bind( &addTestOrTags, "test name, pattern or tags" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4797
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4798 cli["-d"]["--durations"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4799 .describe( "show test durations" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4800 .bind( &setShowDurations, "yes|no" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4801
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4802 cli["-f"]["--input-file"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4803 .describe( "load test names to run from a file" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4804 .bind( &loadTestNamesFromFile, "filename" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4805
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4806 cli["-#"]["--filenames-as-tags"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4807 .describe( "adds a tag for the filename" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4808 .bind( &ConfigData::filenamesAsTags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4809
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4810 // Less common commands which don't have a short form
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4811 cli["--list-test-names-only"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4812 .describe( "list all/matching test cases names only" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4813 .bind( &ConfigData::listTestNamesOnly );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4814
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4815 cli["--list-reporters"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4816 .describe( "list all reporters" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4817 .bind( &ConfigData::listReporters );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4818
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4819 cli["--order"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4820 .describe( "test case order (defaults to decl)" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4821 .bind( &setOrder, "decl|lex|rand" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4822
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4823 cli["--rng-seed"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4824 .describe( "set a specific seed for random numbers" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4825 .bind( &setRngSeed, "'time'|number" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4826
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4827 cli["--force-colour"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4828 .describe( "force colourised output (deprecated)" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4829 .bind( &forceColour );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4830
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4831 cli["--use-colour"]
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4832 .describe( "should output be colourised" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4833 .bind( &setUseColour, "yes|no" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4834
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4835 return cli;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4836 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4837
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4838 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4839
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4840 // #included from: internal/catch_list.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4841 #define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4842
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4843 // #included from: catch_text.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4844 #define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4845
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4846 #define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4847
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4848 #define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4849 // #included from: ../external/tbc_text_format.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4850 // Only use header guard if we are not using an outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4851 #ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4852 # ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4853 # ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4854 # define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4855 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4856 # else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4857 # define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4858 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4859 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4860 #ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4861 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4862 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4863 #include <sstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4864
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4865 // Use optional outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4866 #ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4867 namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4868 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4869
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4870 namespace Tbc {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4871
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4872 #ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4873 const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4874 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4875 const unsigned int consoleWidth = 80;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4876 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4877
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4878 struct TextAttributes {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4879 TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4880 : initialIndent( std::string::npos ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4881 indent( 0 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4882 width( consoleWidth-1 ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4883 tabChar( '\t' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4884 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4885
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4886 TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4887 TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4888 TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4889 TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4890
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4891 std::size_t initialIndent; // indent of first line, or npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4892 std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4893 std::size_t width; // maximum width of text, including indent. Longer text will wrap
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4894 char tabChar; // If this char is seen the indent is changed to current pos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4895 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4896
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4897 class Text {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4898 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4899 Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4900 : attr( _attr )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4901 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4902 std::string wrappableChars = " [({.,/|\\-";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4903 std::size_t indent = _attr.initialIndent != std::string::npos
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4904 ? _attr.initialIndent
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4905 : _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4906 std::string remainder = _str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4907
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4908 while( !remainder.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4909 if( lines.size() >= 1000 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4910 lines.push_back( "... message truncated due to excessive size" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4911 return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4912 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4913 std::size_t tabPos = std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4914 std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4915 std::size_t pos = remainder.find_first_of( '\n' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4916 if( pos <= width ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4917 width = pos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4918 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4919 pos = remainder.find_last_of( _attr.tabChar, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4920 if( pos != std::string::npos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4921 tabPos = pos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4922 if( remainder[width] == '\n' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4923 width--;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4924 remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4925 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4926
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4927 if( width == remainder.size() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4928 spliceLine( indent, remainder, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4929 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4930 else if( remainder[width] == '\n' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4931 spliceLine( indent, remainder, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4932 if( width <= 1 || remainder.size() != 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4933 remainder = remainder.substr( 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4934 indent = _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4935 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4936 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4937 pos = remainder.find_last_of( wrappableChars, width );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4938 if( pos != std::string::npos && pos > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4939 spliceLine( indent, remainder, pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4940 if( remainder[0] == ' ' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4941 remainder = remainder.substr( 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4942 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4943 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4944 spliceLine( indent, remainder, width-1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4945 lines.back() += "-";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4946 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4947 if( lines.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4948 indent = _attr.indent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4949 if( tabPos != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4950 indent += tabPos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4951 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4952 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4953 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4954
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4955 void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4956 lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4957 _remainder = _remainder.substr( _pos );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4958 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4959
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4960 typedef std::vector<std::string>::const_iterator const_iterator;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4961
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4962 const_iterator begin() const { return lines.begin(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4963 const_iterator end() const { return lines.end(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4964 std::string const& last() const { return lines.back(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4965 std::size_t size() const { return lines.size(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4966 std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4967 std::string toString() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4968 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4969 oss << *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4970 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4971 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4972
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4973 inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4974 for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4975 it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4976 if( it != _text.begin() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4977 _stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4978 _stream << *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4979 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4980 return _stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4981 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4982
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4983 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4984 std::string str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4985 TextAttributes attr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4986 std::vector<std::string> lines;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4987 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4988
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4989 } // end namespace Tbc
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4990
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4991 #ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4992 } // end outer namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4993 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4994
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4995 #endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4996 #undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4997
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4998 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
4999 using Tbc::Text;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5000 using Tbc::TextAttributes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5001 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5002
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5003 // #included from: catch_console_colour.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5004 #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5005
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5006 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5007
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5008 struct Colour {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5009 enum Code {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5010 None = 0,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5011
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5012 White,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5013 Red,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5014 Green,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5015 Blue,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5016 Cyan,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5017 Yellow,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5018 Grey,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5019
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5020 Bright = 0x10,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5021
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5022 BrightRed = Bright | Red,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5023 BrightGreen = Bright | Green,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5024 LightGrey = Bright | Grey,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5025 BrightWhite = Bright | White,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5026
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5027 // By intention
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5028 FileName = LightGrey,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5029 Warning = Yellow,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5030 ResultError = BrightRed,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5031 ResultSuccess = BrightGreen,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5032 ResultExpectedFailure = Warning,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5033
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5034 Error = BrightRed,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5035 Success = Green,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5036
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5037 OriginalExpression = Cyan,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5038 ReconstructedExpression = Yellow,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5039
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5040 SecondaryText = LightGrey,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5041 Headers = White
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5042 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5043
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5044 // Use constructed object for RAII guard
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5045 Colour( Code _colourCode );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5046 Colour( Colour const& other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5047 ~Colour();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5048
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5049 // Use static method for one-shot changes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5050 static void use( Code _colourCode );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5051
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5052 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5053 bool m_moved;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5054 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5055
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5056 inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5057
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5058 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5059
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5060 // #included from: catch_interfaces_reporter.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5061 #define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5062
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5063 #include <string>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5064 #include <ostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5065 #include <map>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5066 #include <assert.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5067
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5068 namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5069 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5070 struct ReporterConfig {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5071 explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5072 : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5073
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5074 ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream& _stream )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5075 : m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5076
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5077 std::ostream& stream() const { return *m_stream; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5078 Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5079
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5080 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5081 std::ostream* m_stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5082 Ptr<IConfig const> m_fullConfig;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5083 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5084
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5085 struct ReporterPreferences {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5086 ReporterPreferences()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5087 : shouldRedirectStdOut( false )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5088 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5089
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5090 bool shouldRedirectStdOut;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5091 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5092
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5093 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5094 struct LazyStat : Option<T> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5095 LazyStat() : used( false ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5096 LazyStat& operator=( T const& _value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5097 Option<T>::operator=( _value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5098 used = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5099 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5100 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5101 void reset() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5102 Option<T>::reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5103 used = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5104 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5105 bool used;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5106 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5107
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5108 struct TestRunInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5109 TestRunInfo( std::string const& _name ) : name( _name ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5110 std::string name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5111 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5112 struct GroupInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5113 GroupInfo( std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5114 std::size_t _groupIndex,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5115 std::size_t _groupsCount )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5116 : name( _name ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5117 groupIndex( _groupIndex ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5118 groupsCounts( _groupsCount )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5119 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5120
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5121 std::string name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5122 std::size_t groupIndex;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5123 std::size_t groupsCounts;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5124 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5125
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5126 struct AssertionStats {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5127 AssertionStats( AssertionResult const& _assertionResult,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5128 std::vector<MessageInfo> const& _infoMessages,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5129 Totals const& _totals )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5130 : assertionResult( _assertionResult ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5131 infoMessages( _infoMessages ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5132 totals( _totals )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5133 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5134 if( assertionResult.hasMessage() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5135 // Copy message into messages list.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5136 // !TBD This should have been done earlier, somewhere
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5137 MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5138 builder << assertionResult.getMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5139 builder.m_info.message = builder.m_stream.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5140
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5141 infoMessages.push_back( builder.m_info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5142 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5143 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5144 virtual ~AssertionStats();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5145
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5146 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5147 AssertionStats( AssertionStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5148 AssertionStats( AssertionStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5149 AssertionStats& operator = ( AssertionStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5150 AssertionStats& operator = ( AssertionStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5151 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5152
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5153 AssertionResult assertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5154 std::vector<MessageInfo> infoMessages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5155 Totals totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5156 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5157
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5158 struct SectionStats {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5159 SectionStats( SectionInfo const& _sectionInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5160 Counts const& _assertions,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5161 double _durationInSeconds,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5162 bool _missingAssertions )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5163 : sectionInfo( _sectionInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5164 assertions( _assertions ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5165 durationInSeconds( _durationInSeconds ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5166 missingAssertions( _missingAssertions )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5167 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5168 virtual ~SectionStats();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5169 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5170 SectionStats( SectionStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5171 SectionStats( SectionStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5172 SectionStats& operator = ( SectionStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5173 SectionStats& operator = ( SectionStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5174 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5175
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5176 SectionInfo sectionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5177 Counts assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5178 double durationInSeconds;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5179 bool missingAssertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5180 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5181
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5182 struct TestCaseStats {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5183 TestCaseStats( TestCaseInfo const& _testInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5184 Totals const& _totals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5185 std::string const& _stdOut,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5186 std::string const& _stdErr,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5187 bool _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5188 : testInfo( _testInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5189 totals( _totals ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5190 stdOut( _stdOut ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5191 stdErr( _stdErr ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5192 aborting( _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5193 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5194 virtual ~TestCaseStats();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5195
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5196 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5197 TestCaseStats( TestCaseStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5198 TestCaseStats( TestCaseStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5199 TestCaseStats& operator = ( TestCaseStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5200 TestCaseStats& operator = ( TestCaseStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5201 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5202
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5203 TestCaseInfo testInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5204 Totals totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5205 std::string stdOut;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5206 std::string stdErr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5207 bool aborting;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5208 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5209
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5210 struct TestGroupStats {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5211 TestGroupStats( GroupInfo const& _groupInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5212 Totals const& _totals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5213 bool _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5214 : groupInfo( _groupInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5215 totals( _totals ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5216 aborting( _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5217 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5218 TestGroupStats( GroupInfo const& _groupInfo )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5219 : groupInfo( _groupInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5220 aborting( false )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5221 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5222 virtual ~TestGroupStats();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5223
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5224 # ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5225 TestGroupStats( TestGroupStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5226 TestGroupStats( TestGroupStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5227 TestGroupStats& operator = ( TestGroupStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5228 TestGroupStats& operator = ( TestGroupStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5229 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5230
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5231 GroupInfo groupInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5232 Totals totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5233 bool aborting;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5234 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5235
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5236 struct TestRunStats {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5237 TestRunStats( TestRunInfo const& _runInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5238 Totals const& _totals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5239 bool _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5240 : runInfo( _runInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5241 totals( _totals ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5242 aborting( _aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5243 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5244 virtual ~TestRunStats();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5245
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5246 # ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5247 TestRunStats( TestRunStats const& _other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5248 : runInfo( _other.runInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5249 totals( _other.totals ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5250 aborting( _other.aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5251 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5252 # else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5253 TestRunStats( TestRunStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5254 TestRunStats( TestRunStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5255 TestRunStats& operator = ( TestRunStats const& ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5256 TestRunStats& operator = ( TestRunStats && ) = default;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5257 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5258
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5259 TestRunInfo runInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5260 Totals totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5261 bool aborting;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5262 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5263
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5264 class MultipleReporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5265
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5266 struct IStreamingReporter : IShared {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5267 virtual ~IStreamingReporter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5268
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5269 // Implementing class must also provide the following static method:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5270 // static std::string getDescription();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5271
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5272 virtual ReporterPreferences getPreferences() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5273
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5274 virtual void noMatchingTestCases( std::string const& spec ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5275
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5276 virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5277 virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5278
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5279 virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5280 virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5281
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5282 virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5283
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5284 // The return value indicates if the messages buffer should be cleared:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5285 virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5286
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5287 virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5288 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5289 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5290 virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5291
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5292 virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5293
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5294 virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5295 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5296
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5297 struct IReporterFactory : IShared {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5298 virtual ~IReporterFactory();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5299 virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5300 virtual std::string getDescription() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5301 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5302
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5303 struct IReporterRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5304 typedef std::map<std::string, Ptr<IReporterFactory> > FactoryMap;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5305 typedef std::vector<Ptr<IReporterFactory> > Listeners;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5306
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5307 virtual ~IReporterRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5308 virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5309 virtual FactoryMap const& getFactories() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5310 virtual Listeners const& getListeners() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5311 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5312
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5313 Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5314
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5315 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5316
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5317 #include <limits>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5318 #include <algorithm>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5319
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5320 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5321
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5322 inline std::size_t listTests( Config const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5323
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5324 TestSpec testSpec = config.testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5325 if( config.testSpec().hasFilters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5326 Catch::cout() << "Matching test cases:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5327 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5328 Catch::cout() << "All available test cases:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5329 testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5330 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5331
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5332 std::size_t matchedTests = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5333 TextAttributes nameAttr, tagsAttr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5334 nameAttr.setInitialIndent( 2 ).setIndent( 4 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5335 tagsAttr.setIndent( 6 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5336
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5337 std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5338 for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5339 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5340 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5341 matchedTests++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5342 TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5343 Colour::Code colour = testCaseInfo.isHidden()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5344 ? Colour::SecondaryText
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5345 : Colour::None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5346 Colour colourGuard( colour );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5347
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5348 Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5349 if( !testCaseInfo.tags.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5350 Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5351 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5352
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5353 if( !config.testSpec().hasFilters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5354 Catch::cout() << pluralise( matchedTests, "test case" ) << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5355 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5356 Catch::cout() << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5357 return matchedTests;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5358 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5359
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5360 inline std::size_t listTestsNamesOnly( Config const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5361 TestSpec testSpec = config.testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5362 if( !config.testSpec().hasFilters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5363 testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5364 std::size_t matchedTests = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5365 std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5366 for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5367 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5368 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5369 matchedTests++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5370 TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5371 Catch::cout() << testCaseInfo.name << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5372 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5373 return matchedTests;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5374 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5375
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5376 struct TagInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5377 TagInfo() : count ( 0 ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5378 void add( std::string const& spelling ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5379 ++count;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5380 spellings.insert( spelling );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5381 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5382 std::string all() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5383 std::string out;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5384 for( std::set<std::string>::const_iterator it = spellings.begin(), itEnd = spellings.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5385 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5386 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5387 out += "[" + *it + "]";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5388 return out;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5389 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5390 std::set<std::string> spellings;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5391 std::size_t count;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5392 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5393
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5394 inline std::size_t listTags( Config const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5395 TestSpec testSpec = config.testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5396 if( config.testSpec().hasFilters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5397 Catch::cout() << "Tags for matching test cases:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5398 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5399 Catch::cout() << "All available tags:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5400 testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5401 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5402
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5403 std::map<std::string, TagInfo> tagCounts;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5404
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5405 std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5406 for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5407 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5408 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5409 for( std::set<std::string>::const_iterator tagIt = it->getTestCaseInfo().tags.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5410 tagItEnd = it->getTestCaseInfo().tags.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5411 tagIt != tagItEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5412 ++tagIt ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5413 std::string tagName = *tagIt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5414 std::string lcaseTagName = toLower( tagName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5415 std::map<std::string, TagInfo>::iterator countIt = tagCounts.find( lcaseTagName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5416 if( countIt == tagCounts.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5417 countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5418 countIt->second.add( tagName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5419 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5420 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5421
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5422 for( std::map<std::string, TagInfo>::const_iterator countIt = tagCounts.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5423 countItEnd = tagCounts.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5424 countIt != countItEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5425 ++countIt ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5426 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5427 oss << " " << std::setw(2) << countIt->second.count << " ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5428 Text wrapper( countIt->second.all(), TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5429 .setInitialIndent( 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5430 .setIndent( oss.str().size() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5431 .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5432 Catch::cout() << oss.str() << wrapper << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5433 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5434 Catch::cout() << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5435 return tagCounts.size();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5436 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5437
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5438 inline std::size_t listReporters( Config const& /*config*/ ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5439 Catch::cout() << "Available reporters:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5440 IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5441 IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5442 std::size_t maxNameLen = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5443 for(it = itBegin; it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5444 maxNameLen = (std::max)( maxNameLen, it->first.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5445
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5446 for(it = itBegin; it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5447 Text wrapper( it->second->getDescription(), TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5448 .setInitialIndent( 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5449 .setIndent( 7+maxNameLen )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5450 .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5451 Catch::cout() << " "
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5452 << it->first
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5453 << ":"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5454 << std::string( maxNameLen - it->first.size() + 2, ' ' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5455 << wrapper << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5456 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5457 Catch::cout() << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5458 return factories.size();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5459 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5460
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5461 inline Option<std::size_t> list( Config const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5462 Option<std::size_t> listedCount;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5463 if( config.listTests() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5464 listedCount = listedCount.valueOr(0) + listTests( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5465 if( config.listTestNamesOnly() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5466 listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5467 if( config.listTags() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5468 listedCount = listedCount.valueOr(0) + listTags( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5469 if( config.listReporters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5470 listedCount = listedCount.valueOr(0) + listReporters( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5471 return listedCount;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5472 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5473
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5474 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5475
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5476 // #included from: internal/catch_run_context.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5477 #define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5478
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5479 // #included from: catch_test_case_tracker.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5480 #define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5481
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5482 #include <map>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5483 #include <string>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5484 #include <assert.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5485 #include <vector>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5486
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5487 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5488 namespace TestCaseTracking {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5489
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5490 struct ITracker : SharedImpl<> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5491 virtual ~ITracker();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5492
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5493 // static queries
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5494 virtual std::string name() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5495
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5496 // dynamic queries
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5497 virtual bool isComplete() const = 0; // Successfully completed or failed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5498 virtual bool isSuccessfullyCompleted() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5499 virtual bool isOpen() const = 0; // Started but not complete
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5500 virtual bool hasChildren() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5501
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5502 virtual ITracker& parent() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5503
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5504 // actions
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5505 virtual void close() = 0; // Successfully complete
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5506 virtual void fail() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5507 virtual void markAsNeedingAnotherRun() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5508
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5509 virtual void addChild( Ptr<ITracker> const& child ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5510 virtual ITracker* findChild( std::string const& name ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5511 virtual void openChild() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5512
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5513 // Debug/ checking
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5514 virtual bool isSectionTracker() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5515 virtual bool isIndexTracker() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5516 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5517
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5518 class TrackerContext {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5519
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5520 enum RunState {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5521 NotStarted,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5522 Executing,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5523 CompletedCycle
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5524 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5525
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5526 Ptr<ITracker> m_rootTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5527 ITracker* m_currentTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5528 RunState m_runState;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5529
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5530 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5531
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5532 static TrackerContext& instance() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5533 static TrackerContext s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5534 return s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5535 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5536
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5537 TrackerContext()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5538 : m_currentTracker( CATCH_NULL ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5539 m_runState( NotStarted )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5540 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5541
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5542 ITracker& startRun();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5543
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5544 void endRun() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5545 m_rootTracker.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5546 m_currentTracker = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5547 m_runState = NotStarted;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5548 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5549
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5550 void startCycle() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5551 m_currentTracker = m_rootTracker.get();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5552 m_runState = Executing;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5553 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5554 void completeCycle() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5555 m_runState = CompletedCycle;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5556 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5557
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5558 bool completedCycle() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5559 return m_runState == CompletedCycle;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5560 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5561 ITracker& currentTracker() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5562 return *m_currentTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5563 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5564 void setCurrentTracker( ITracker* tracker ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5565 m_currentTracker = tracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5566 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5567 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5568
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5569 class TrackerBase : public ITracker {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5570 protected:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5571 enum CycleState {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5572 NotStarted,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5573 Executing,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5574 ExecutingChildren,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5575 NeedsAnotherRun,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5576 CompletedSuccessfully,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5577 Failed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5578 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5579 class TrackerHasName {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5580 std::string m_name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5581 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5582 TrackerHasName( std::string const& name ) : m_name( name ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5583 bool operator ()( Ptr<ITracker> const& tracker ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5584 return tracker->name() == m_name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5585 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5586 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5587 typedef std::vector<Ptr<ITracker> > Children;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5588 std::string m_name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5589 TrackerContext& m_ctx;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5590 ITracker* m_parent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5591 Children m_children;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5592 CycleState m_runState;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5593 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5594 TrackerBase( std::string const& name, TrackerContext& ctx, ITracker* parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5595 : m_name( name ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5596 m_ctx( ctx ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5597 m_parent( parent ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5598 m_runState( NotStarted )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5599 {}
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5600 virtual ~TrackerBase();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5601
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5602 virtual std::string name() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5603 return m_name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5604 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5605 virtual bool isComplete() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5606 return m_runState == CompletedSuccessfully || m_runState == Failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5607 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5608 virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5609 return m_runState == CompletedSuccessfully;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5610 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5611 virtual bool isOpen() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5612 return m_runState != NotStarted && !isComplete();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5613 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5614 virtual bool hasChildren() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5615 return !m_children.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5616 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5617
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5618 virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5619 m_children.push_back( child );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5620 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5621
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5622 virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5623 Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5624 return( it != m_children.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5625 ? it->get()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5626 : CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5627 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5628 virtual ITracker& parent() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5629 assert( m_parent ); // Should always be non-null except for root
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5630 return *m_parent;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5631 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5632
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5633 virtual void openChild() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5634 if( m_runState != ExecutingChildren ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5635 m_runState = ExecutingChildren;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5636 if( m_parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5637 m_parent->openChild();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5638 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5639 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5640
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5641 virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5642 virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5643
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5644 void open() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5645 m_runState = Executing;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5646 moveToThis();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5647 if( m_parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5648 m_parent->openChild();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5649 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5650
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5651 virtual void close() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5652
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5653 // Close any still open children (e.g. generators)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5654 while( &m_ctx.currentTracker() != this )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5655 m_ctx.currentTracker().close();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5656
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5657 switch( m_runState ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5658 case NotStarted:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5659 case CompletedSuccessfully:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5660 case Failed:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5661 throw std::logic_error( "Illogical state" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5662
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5663 case NeedsAnotherRun:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5664 break;;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5665
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5666 case Executing:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5667 m_runState = CompletedSuccessfully;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5668 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5669 case ExecutingChildren:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5670 if( m_children.empty() || m_children.back()->isComplete() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5671 m_runState = CompletedSuccessfully;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5672 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5673
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5674 default:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5675 throw std::logic_error( "Unexpected state" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5676 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5677 moveToParent();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5678 m_ctx.completeCycle();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5679 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5680 virtual void fail() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5681 m_runState = Failed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5682 if( m_parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5683 m_parent->markAsNeedingAnotherRun();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5684 moveToParent();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5685 m_ctx.completeCycle();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5686 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5687 virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5688 m_runState = NeedsAnotherRun;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5689 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5690 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5691 void moveToParent() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5692 assert( m_parent );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5693 m_ctx.setCurrentTracker( m_parent );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5694 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5695 void moveToThis() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5696 m_ctx.setCurrentTracker( this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5697 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5698 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5699
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5700 class SectionTracker : public TrackerBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5701 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5702 SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5703 : TrackerBase( name, ctx, parent )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5704 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5705 virtual ~SectionTracker();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5706
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5707 virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5708
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5709 static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5710 SectionTracker* section = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5711
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5712 ITracker& currentTracker = ctx.currentTracker();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5713 if( ITracker* childTracker = currentTracker.findChild( name ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5714 assert( childTracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5715 assert( childTracker->isSectionTracker() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5716 section = static_cast<SectionTracker*>( childTracker );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5717 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5718 else {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5719 section = new SectionTracker( name, ctx, &currentTracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5720 currentTracker.addChild( section );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5721 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5722 if( !ctx.completedCycle() && !section->isComplete() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5723
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5724 section->open();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5725 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5726 return *section;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5727 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5728 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5729
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5730 class IndexTracker : public TrackerBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5731 int m_size;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5732 int m_index;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5733 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5734 IndexTracker( std::string const& name, TrackerContext& ctx, ITracker* parent, int size )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5735 : TrackerBase( name, ctx, parent ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5736 m_size( size ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5737 m_index( -1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5738 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5739 virtual ~IndexTracker();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5740
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5741 virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5742
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5743 static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5744 IndexTracker* tracker = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5745
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5746 ITracker& currentTracker = ctx.currentTracker();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5747 if( ITracker* childTracker = currentTracker.findChild( name ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5748 assert( childTracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5749 assert( childTracker->isIndexTracker() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5750 tracker = static_cast<IndexTracker*>( childTracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5751 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5752 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5753 tracker = new IndexTracker( name, ctx, &currentTracker, size );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5754 currentTracker.addChild( tracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5755 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5756
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5757 if( !ctx.completedCycle() && !tracker->isComplete() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5758 if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5759 tracker->moveNext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5760 tracker->open();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5761 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5762
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5763 return *tracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5764 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5765
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5766 int index() const { return m_index; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5767
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5768 void moveNext() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5769 m_index++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5770 m_children.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5771 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5772
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5773 virtual void close() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5774 TrackerBase::close();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5775 if( m_runState == CompletedSuccessfully && m_index < m_size-1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5776 m_runState = Executing;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5777 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5778 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5779
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5780 inline ITracker& TrackerContext::startRun() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5781 m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5782 m_currentTracker = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5783 m_runState = Executing;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5784 return *m_rootTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5785 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5786
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5787 } // namespace TestCaseTracking
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5788
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5789 using TestCaseTracking::ITracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5790 using TestCaseTracking::TrackerContext;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5791 using TestCaseTracking::SectionTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5792 using TestCaseTracking::IndexTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5793
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5794 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5795
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5796 // #included from: catch_fatal_condition.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5797 #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5798
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5799 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5800
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5801 // Report the error condition then exit the process
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5802 inline void fatal( std::string const& message, int exitCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5803 IContext& context = Catch::getCurrentContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5804 IResultCapture* resultCapture = context.getResultCapture();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5805 resultCapture->handleFatalErrorCondition( message );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5807 if( Catch::alwaysTrue() ) // avoids "no return" warnings
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5808 exit( exitCode );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5809 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5810
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5811 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5812
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5813 #if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5814
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5815 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5816
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5817 struct FatalConditionHandler {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5818 void reset() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5819 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5820
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5821 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5822
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5823 #else // Not Windows - assumed to be POSIX compatible //////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5824
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5825 #include <signal.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5826
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5827 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5828
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5829 struct SignalDefs { int id; const char* name; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5830 extern SignalDefs signalDefs[];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5831 SignalDefs signalDefs[] = {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5832 { SIGINT, "SIGINT - Terminal interrupt signal" },
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5833 { SIGILL, "SIGILL - Illegal instruction signal" },
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5834 { SIGFPE, "SIGFPE - Floating point error signal" },
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5835 { SIGSEGV, "SIGSEGV - Segmentation violation signal" },
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5836 { SIGTERM, "SIGTERM - Termination request signal" },
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5837 { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5838 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5839
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5840 struct FatalConditionHandler {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5841
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5842 static void handleSignal( int sig ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5843 for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5844 if( sig == signalDefs[i].id )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5845 fatal( signalDefs[i].name, -sig );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5846 fatal( "<unknown signal>", -sig );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5847 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5848
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5849 FatalConditionHandler() : m_isSet( true ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5850 for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5851 signal( signalDefs[i].id, handleSignal );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5852 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5853 ~FatalConditionHandler() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5854 reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5855 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5856 void reset() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5857 if( m_isSet ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5858 for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5859 signal( signalDefs[i].id, SIG_DFL );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5860 m_isSet = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5861 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5862 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5863
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5864 bool m_isSet;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5865 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5866
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5867 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5868
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5869 #endif // not Windows
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5870
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5871 #include <set>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5872 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5873
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5874 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5875
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5876 class StreamRedirect {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5877
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5878 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5879 StreamRedirect( std::ostream& stream, std::string& targetString )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5880 : m_stream( stream ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5881 m_prevBuf( stream.rdbuf() ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5882 m_targetString( targetString )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5883 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5884 stream.rdbuf( m_oss.rdbuf() );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5885 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5886
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5887 ~StreamRedirect() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5888 m_targetString += m_oss.str();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5889 m_stream.rdbuf( m_prevBuf );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5890 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5891
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5892 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5893 std::ostream& m_stream;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5894 std::streambuf* m_prevBuf;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5895 std::ostringstream m_oss;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5896 std::string& m_targetString;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5897 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5898
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5899 ///////////////////////////////////////////////////////////////////////////
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5900
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5901 class RunContext : public IResultCapture, public IRunner {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5902
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5903 RunContext( RunContext const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5904 void operator =( RunContext const& );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5905
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5906 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5907
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5908 explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5909 : m_runInfo( _config->name() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5910 m_context( getCurrentMutableContext() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5911 m_activeTestCase( CATCH_NULL ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5912 m_config( _config ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5913 m_reporter( reporter )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5914 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5915 m_context.setRunner( this );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5916 m_context.setConfig( m_config );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5917 m_context.setResultCapture( this );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5918 m_reporter->testRunStarting( m_runInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5919 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5920
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5921 virtual ~RunContext() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5922 m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5923 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5924
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5925 void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5926 m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5927 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5928 void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5929 m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5930 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5931
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5932 Totals runTest( TestCase const& testCase ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5933 Totals prevTotals = m_totals;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5934
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5935 std::string redirectedCout;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5936 std::string redirectedCerr;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5937
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5938 TestCaseInfo testInfo = testCase.getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5939
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5940 m_reporter->testCaseStarting( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5941
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5942 m_activeTestCase = &testCase;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5943
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5944 do {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5945 m_trackerContext.startRun();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5946 do {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5947 m_trackerContext.startCycle();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5948 m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testInfo.name );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5949 runCurrentTest( redirectedCout, redirectedCerr );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5950 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5951 while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5952 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5953 // !TBD: deprecated - this will be replaced by indexed trackers
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5954 while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5955
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5956 Totals deltaTotals = m_totals.delta( prevTotals );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5957 if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5958 deltaTotals.assertions.failed++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5959 deltaTotals.testCases.passed--;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5960 deltaTotals.testCases.failed++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5961 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5962 m_totals.testCases += deltaTotals.testCases;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5963 m_reporter->testCaseEnded( TestCaseStats( testInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5964 deltaTotals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5965 redirectedCout,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5966 redirectedCerr,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5967 aborting() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5968
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5969 m_activeTestCase = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5970 m_testCaseTracker = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5971
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5972 return deltaTotals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5973 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5974
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5975 Ptr<IConfig const> config() const {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5976 return m_config;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5977 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5978
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5979 private: // IResultCapture
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5980
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5981 virtual void assertionEnded( AssertionResult const& result ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5982 if( result.getResultType() == ResultWas::Ok ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5983 m_totals.assertions.passed++;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5984 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5985 else if( !result.isOk() ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5986 m_totals.assertions.failed++;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5987 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5988
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5989 if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5990 m_messages.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5991
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5992 // Reset working state
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5993 m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5994 m_lastResult = result;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5995 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5996
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5997 virtual bool sectionStarted (
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
5998 SectionInfo const& sectionInfo,
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5999 Counts& assertions
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6000 )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6001 {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6002 std::ostringstream oss;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6003 oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6004
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6005 ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6006 if( !sectionTracker.isOpen() )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6007 return false;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6008 m_activeSections.push_back( &sectionTracker );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6009
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6010 m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6011
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6012 m_reporter->sectionStarting( sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6013
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6014 assertions = m_totals.assertions;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6015
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6016 return true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6017 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6018 bool testForMissingAssertions( Counts& assertions ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6019 if( assertions.total() != 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6020 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6021 if( !m_config->warnAboutMissingAssertions() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6022 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6023 if( m_trackerContext.currentTracker().hasChildren() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6024 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6025 m_totals.assertions.failed++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6026 assertions.failed++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6027 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6028 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6029
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6030 virtual void sectionEnded( SectionEndInfo const& endInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6031 Counts assertions = m_totals.assertions - endInfo.prevAssertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6032 bool missingAssertions = testForMissingAssertions( assertions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6033
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6034 if( !m_activeSections.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6035 m_activeSections.back()->close();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6036 m_activeSections.pop_back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6037 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6039 m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6040 m_messages.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6041 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6042
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6043 virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6044 if( m_unfinishedSections.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6045 m_activeSections.back()->fail();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6046 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6047 m_activeSections.back()->close();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6048 m_activeSections.pop_back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6049
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6050 m_unfinishedSections.push_back( endInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6051 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6052
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6053 virtual void pushScopedMessage( MessageInfo const& message ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6054 m_messages.push_back( message );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6055 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6056
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6057 virtual void popScopedMessage( MessageInfo const& message ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6058 m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6059 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6060
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6061 virtual std::string getCurrentTestName() const {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6062 return m_activeTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6063 ? m_activeTestCase->getTestCaseInfo().name
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6064 : "";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6065 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6066
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6067 virtual const AssertionResult* getLastResult() const {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6068 return &m_lastResult;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6069 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6070
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6071 virtual void handleFatalErrorCondition( std::string const& message ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6072 ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6073 resultBuilder.setResultType( ResultWas::FatalErrorCondition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6074 resultBuilder << message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6075 resultBuilder.captureExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6076
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6077 handleUnfinishedSections();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6078
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6079 // Recreate section for test case (as we will lose the one that was in scope)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6080 TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6081 SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6082
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6083 Counts assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6084 assertions.failed = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6085 SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6086 m_reporter->sectionEnded( testCaseSectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6087
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6088 TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6089
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6090 Totals deltaTotals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6091 deltaTotals.testCases.failed = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6092 m_reporter->testCaseEnded( TestCaseStats( testInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6093 deltaTotals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6094 "",
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6095 "",
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6096 false ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6097 m_totals.testCases.failed++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6098 testGroupEnded( "", m_totals, 1, 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6099 m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6100 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6101
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6102 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6103 // !TBD We need to do this another way!
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6104 bool aborting() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6105 return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6106 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6107
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6108 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6109
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6110 void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6111 TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6112 SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6113 m_reporter->sectionStarting( testCaseSection );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6114 Counts prevAssertions = m_totals.assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6115 double duration = 0;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6116 try {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6117 m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6118
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6119 seedRng( *m_config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6120
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6121 Timer timer;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6122 timer.start();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6123 if( m_reporter->getPreferences().shouldRedirectStdOut ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6124 StreamRedirect coutRedir( Catch::cout(), redirectedCout );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6125 StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6126 invokeActiveTestCase();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6127 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6128 else {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6129 invokeActiveTestCase();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6130 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6131 duration = timer.getElapsedSeconds();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6132 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6133 catch( TestFailureException& ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6134 // This just means the test was aborted due to failure
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6135 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6136 catch(...) {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6137 makeUnexpectedResultBuilder().useActiveException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6138 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6139 m_testCaseTracker->close();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6140 handleUnfinishedSections();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6141 m_messages.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6142
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6143 Counts assertions = m_totals.assertions - prevAssertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6144 bool missingAssertions = testForMissingAssertions( assertions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6145
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6146 if( testCaseInfo.okToFail() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6147 std::swap( assertions.failedButOk, assertions.failed );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6148 m_totals.assertions.failed -= assertions.failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6149 m_totals.assertions.failedButOk += assertions.failedButOk;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6150 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6151
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6152 SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6153 m_reporter->sectionEnded( testCaseSectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6154 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6155
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6156 void invokeActiveTestCase() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6157 FatalConditionHandler fatalConditionHandler; // Handle signals
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6158 m_activeTestCase->invoke();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6159 fatalConditionHandler.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6160 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6161
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6162 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6163
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6164 ResultBuilder makeUnexpectedResultBuilder() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6165 return ResultBuilder( m_lastAssertionInfo.macroName.c_str(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6166 m_lastAssertionInfo.lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6167 m_lastAssertionInfo.capturedExpression.c_str(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6168 m_lastAssertionInfo.resultDisposition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6169 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6170
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6171 void handleUnfinishedSections() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6172 // If sections ended prematurely due to an exception we stored their
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6173 // infos here so we can tear them down outside the unwind process.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6174 for( std::vector<SectionEndInfo>::const_reverse_iterator it = m_unfinishedSections.rbegin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6175 itEnd = m_unfinishedSections.rend();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6176 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6177 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6178 sectionEnded( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6179 m_unfinishedSections.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6180 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6181
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6182 TestRunInfo m_runInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6183 IMutableContext& m_context;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6184 TestCase const* m_activeTestCase;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6185 ITracker* m_testCaseTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6186 ITracker* m_currentSectionTracker;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6187 AssertionResult m_lastResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6188
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6189 Ptr<IConfig const> m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6190 Totals m_totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6191 Ptr<IStreamingReporter> m_reporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6192 std::vector<MessageInfo> m_messages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6193 AssertionInfo m_lastAssertionInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6194 std::vector<SectionEndInfo> m_unfinishedSections;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6195 std::vector<ITracker*> m_activeSections;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6196 TrackerContext m_trackerContext;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6197 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6198
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6199 IResultCapture& getResultCapture() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6200 if( IResultCapture* capture = getCurrentContext().getResultCapture() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6201 return *capture;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6202 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6203 throw std::logic_error( "No result capture instance" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6204 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6205
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6206 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6207
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6208 // #included from: internal/catch_version.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6209 #define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6210
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6211 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6212
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6213 // Versioning information
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6214 struct Version {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6215 Version( unsigned int _majorVersion,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6216 unsigned int _minorVersion,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6217 unsigned int _patchNumber,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6218 std::string const& _branchName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6219 unsigned int _buildNumber );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6220
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6221 unsigned int const majorVersion;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6222 unsigned int const minorVersion;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6223 unsigned int const patchNumber;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6224
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6225 // buildNumber is only used if branchName is not null
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6226 std::string const branchName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6227 unsigned int const buildNumber;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6228
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6229 friend std::ostream& operator << ( std::ostream& os, Version const& version );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6230
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6231 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6232 void operator=( Version const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6233 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6234
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6235 extern Version libraryVersion;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6236 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6237
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6238 #include <fstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6239 #include <stdlib.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6240 #include <limits>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6241
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6242 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6243
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6244 Ptr<IStreamingReporter> createReporter( std::string const& reporterName, Ptr<Config> const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6245 Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6246 if( !reporter ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6247 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6248 oss << "No reporter registered with name: '" << reporterName << "'";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6249 throw std::domain_error( oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6250 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6251 return reporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6252 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6253
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6254 Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6255 std::vector<std::string> reporters = config->getReporterNames();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6256 if( reporters.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6257 reporters.push_back( "console" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6258
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6259 Ptr<IStreamingReporter> reporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6260 for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6261 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6262 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6263 reporter = addReporter( reporter, createReporter( *it, config ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6264 return reporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6265 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6266 Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6267 IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6268 for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6269 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6270 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6271 reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6272 return reporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6273 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6274
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6275 Totals runTests( Ptr<Config> const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6276
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6277 Ptr<IConfig const> iconfig = config.get();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6278
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6279 Ptr<IStreamingReporter> reporter = makeReporter( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6280 reporter = addListeners( iconfig, reporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6281
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6282 RunContext context( iconfig, reporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6283
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6284 Totals totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6285
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6286 context.testGroupStarting( config->name(), 1, 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6287
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6288 TestSpec testSpec = config->testSpec();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6289 if( !testSpec.hasFilters() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6290 testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6291
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6292 std::vector<TestCase> const& allTestCases = getAllTestCasesSorted( *iconfig );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6293 for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6294 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6295 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6296 if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6297 totals += context.runTest( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6298 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6299 reporter->skipTest( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6300 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6301
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6302 context.testGroupEnded( iconfig->name(), totals, 1, 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6303 return totals;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6304 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6305
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6306 void applyFilenamesAsTags( IConfig const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6307 std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6308 for(std::size_t i = 0; i < tests.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6309 TestCase& test = const_cast<TestCase&>( tests[i] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6310 std::set<std::string> tags = test.tags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6311
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6312 std::string filename = test.lineInfo.file;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6313 std::string::size_type lastSlash = filename.find_last_of( "\\/" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6314 if( lastSlash != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6315 filename = filename.substr( lastSlash+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6316
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6317 std::string::size_type lastDot = filename.find_last_of( "." );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6318 if( lastDot != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6319 filename = filename.substr( 0, lastDot );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6320
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6321 tags.insert( "#" + filename );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6322 setTags( test, tags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6323 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6324 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6325
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6326 class Session : NonCopyable {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6327 static bool alreadyInstantiated;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6328
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6329 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6330
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6331 struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6332
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6333 Session()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6334 : m_cli( makeCommandLineParser() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6335 if( alreadyInstantiated ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6336 std::string msg = "Only one instance of Catch::Session can ever be used";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6337 Catch::cerr() << msg << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6338 throw std::logic_error( msg );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6339 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6340 alreadyInstantiated = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6341 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6342 ~Session() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6343 Catch::cleanUp();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6344 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6345
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6346 void showHelp( std::string const& processName ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6347 Catch::cout() << "\nCatch v" << libraryVersion << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6348
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6349 m_cli.usage( Catch::cout(), processName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6350 Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6351 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6352
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6353 int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6354 try {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6355 m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6356 m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6357 if( m_configData.showHelp )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6358 showHelp( m_configData.processName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6359 m_config.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6360 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6361 catch( std::exception& ex ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6362 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6363 Colour colourGuard( Colour::Red );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6364 Catch::cerr()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6365 << "\nError(s) in input:\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6366 << Text( ex.what(), TextAttributes().setIndent(2) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6367 << "\n\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6368 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6369 m_cli.usage( Catch::cout(), m_configData.processName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6370 return (std::numeric_limits<int>::max)();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6371 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6372 return 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6373 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6374
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6375 void useConfigData( ConfigData const& _configData ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6376 m_configData = _configData;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6377 m_config.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6378 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6379
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6380 int run( int argc, char const* const* const argv ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6381
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6382 int returnCode = applyCommandLine( argc, argv );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6383 if( returnCode == 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6384 returnCode = run();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6385 return returnCode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6386 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6387
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6388 int run() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6389 if( m_configData.showHelp )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6390 return 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6391
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6392 try
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6393 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6394 config(); // Force config to be constructed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6395
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6396 seedRng( *m_config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6397
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6398 if( m_configData.filenamesAsTags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6399 applyFilenamesAsTags( *m_config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6400
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6401 // Handle list request
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6402 if( Option<std::size_t> listed = list( config() ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6403 return static_cast<int>( *listed );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6404
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6405 return static_cast<int>( runTests( m_config ).assertions.failed );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6406 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6407 catch( std::exception& ex ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6408 Catch::cerr() << ex.what() << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6409 return (std::numeric_limits<int>::max)();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6410 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6411 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6412
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6413 Clara::CommandLine<ConfigData> const& cli() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6414 return m_cli;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6415 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6416 std::vector<Clara::Parser::Token> const& unusedTokens() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6417 return m_unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6418 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6419 ConfigData& configData() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6420 return m_configData;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6421 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6422 Config& config() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6423 if( !m_config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6424 m_config = new Config( m_configData );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6425 return *m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6426 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6427 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6428 Clara::CommandLine<ConfigData> m_cli;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6429 std::vector<Clara::Parser::Token> m_unusedTokens;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6430 ConfigData m_configData;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6431 Ptr<Config> m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6432 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6433
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6434 bool Session::alreadyInstantiated = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6435
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6436 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6437
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6438 // #included from: catch_registry_hub.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6439 #define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6440
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6441 // #included from: catch_test_case_registry_impl.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6442 #define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6443
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6444 #include <vector>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6445 #include <set>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6446 #include <sstream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6447 #include <iostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6448 #include <algorithm>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6449
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6450 #ifdef CATCH_CPP14_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6451 #include <random>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6452 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6453
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6454 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6455
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6456 struct RandomNumberGenerator {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6457 typedef int result_type;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6458
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6459 result_type operator()( result_type n ) const { return std::rand() % n; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6460
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6461 #ifdef CATCH_CPP14_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6462 static constexpr result_type min() { return 0; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6463 static constexpr result_type max() { return 1000000; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6464 result_type operator()() const { return std::rand() % max(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6465 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6466 template<typename V>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6467 static void shuffle( V& vector ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6468 RandomNumberGenerator rng;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6469 #ifdef CATCH_CPP14_OR_GREATER
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6470 std::shuffle( vector.begin(), vector.end(), rng );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6471 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6472 std::random_shuffle( vector.begin(), vector.end(), rng );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6473 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6474 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6475 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6476
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6477 inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6478
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6479 std::vector<TestCase> sorted = unsortedTestCases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6480
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6481 switch( config.runOrder() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6482 case RunTests::InLexicographicalOrder:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6483 std::sort( sorted.begin(), sorted.end() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6484 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6485 case RunTests::InRandomOrder:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6486 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6487 seedRng( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6488 RandomNumberGenerator::shuffle( sorted );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6489 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6490 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6491 case RunTests::InDeclarationOrder:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6492 // already in declaration order
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6493 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6494 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6495 return sorted;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6496 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6497 bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6498 return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6499 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6500
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6501 void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6502 std::set<TestCase> seenFunctions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6503 for( std::vector<TestCase>::const_iterator it = functions.begin(), itEnd = functions.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6504 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6505 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6506 std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6507 if( !prev.second ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6508 std::ostringstream ss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6509
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6510 ss << Colour( Colour::Red )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6511 << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6512 << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6513 << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6514
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6515 throw std::runtime_error(ss.str());
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6516 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6517 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6518 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6519
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6520 std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6521 std::vector<TestCase> filtered;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6522 filtered.reserve( testCases.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6523 for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6524 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6525 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6526 if( matchTest( *it, testSpec, config ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6527 filtered.push_back( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6528 return filtered;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6529 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6530 std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6531 return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6532 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6533
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6534 class TestRegistry : public ITestCaseRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6535 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6536 TestRegistry()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6537 : m_currentSortOrder( RunTests::InDeclarationOrder ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6538 m_unnamedCount( 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6539 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6540 virtual ~TestRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6541
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6542 virtual void registerTest( TestCase const& testCase ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6543 std::string name = testCase.getTestCaseInfo().name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6544 if( name == "" ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6545 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6546 oss << "Anonymous test case " << ++m_unnamedCount;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6547 return registerTest( testCase.withName( oss.str() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6548 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6549 m_functions.push_back( testCase );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6550 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6551
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6552 virtual std::vector<TestCase> const& getAllTests() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6553 return m_functions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6554 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6555 virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6556 if( m_sortedFunctions.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6557 enforceNoDuplicateTestCases( m_functions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6558
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6559 if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6560 m_sortedFunctions = sortTests( config, m_functions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6561 m_currentSortOrder = config.runOrder();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6562 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6563 return m_sortedFunctions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6564 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6565
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6566 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6567 std::vector<TestCase> m_functions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6568 mutable RunTests::InWhatOrder m_currentSortOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6569 mutable std::vector<TestCase> m_sortedFunctions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6570 size_t m_unnamedCount;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6571 std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6572 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6573
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6574 ///////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6575
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6576 class FreeFunctionTestCase : public SharedImpl<ITestCase> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6577 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6578
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6579 FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6580
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6581 virtual void invoke() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6582 m_fun();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6583 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6584
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6585 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6586 virtual ~FreeFunctionTestCase();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6587
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6588 TestFunction m_fun;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6589 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6590
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6591 inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6592 std::string className = classOrQualifiedMethodName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6593 if( startsWith( className, "&" ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6594 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6595 std::size_t lastColons = className.rfind( "::" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6596 std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6597 if( penultimateColons == std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6598 penultimateColons = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6599 className = className.substr( penultimateColons, lastColons-penultimateColons );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6600 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6601 return className;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6602 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6603
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6604 void registerTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6605 ( ITestCase* testCase,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6606 char const* classOrQualifiedMethodName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6607 NameAndDesc const& nameAndDesc,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6608 SourceLineInfo const& lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6609
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6610 getMutableRegistryHub().registerTest
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6611 ( makeTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6612 ( testCase,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6613 extractClassName( classOrQualifiedMethodName ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6614 nameAndDesc.name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6615 nameAndDesc.description,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6616 lineInfo ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6617 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6618 void registerTestCaseFunction
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6619 ( TestFunction function,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6620 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6621 NameAndDesc const& nameAndDesc ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6622 registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6623 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6624
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6625 ///////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6626
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6627 AutoReg::AutoReg
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6628 ( TestFunction function,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6629 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6630 NameAndDesc const& nameAndDesc ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6631 registerTestCaseFunction( function, lineInfo, nameAndDesc );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6632 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6633
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6634 AutoReg::~AutoReg() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6635
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6636 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6637
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6638 // #included from: catch_reporter_registry.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6639 #define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6640
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6641 #include <map>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6642
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6643 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6644
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6645 class ReporterRegistry : public IReporterRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6646
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6647 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6648
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6649 virtual ~ReporterRegistry() CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6650
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6651 virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6652 FactoryMap::const_iterator it = m_factories.find( name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6653 if( it == m_factories.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6654 return CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6655 return it->second->create( ReporterConfig( config ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6656 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6657
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6658 void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6659 m_factories.insert( std::make_pair( name, factory ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6660 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6661 void registerListener( Ptr<IReporterFactory> const& factory ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6662 m_listeners.push_back( factory );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6663 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6664
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6665 virtual FactoryMap const& getFactories() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6666 return m_factories;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6667 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6668 virtual Listeners const& getListeners() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6669 return m_listeners;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6670 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6671
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6672 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6673 FactoryMap m_factories;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6674 Listeners m_listeners;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6675 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6676 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6677
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6678 // #included from: catch_exception_translator_registry.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6679 #define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6680
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6681 #ifdef __OBJC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6682 #import "Foundation/Foundation.h"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6683 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6684
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6685 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6686
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6687 class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6688 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6689 ~ExceptionTranslatorRegistry() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6690 deleteAll( m_translators );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6691 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6692
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6693 virtual void registerTranslator( const IExceptionTranslator* translator ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6694 m_translators.push_back( translator );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6695 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6696
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6697 virtual std::string translateActiveException() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6698 try {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6699 #ifdef __OBJC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6700 // In Objective-C try objective-c exceptions first
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6701 @try {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6702 return tryTranslators();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6703 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6704 @catch (NSException *exception) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6705 return Catch::toString( [exception description] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6706 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6707 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6708 return tryTranslators();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6709 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6710 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6711 catch( TestFailureException& ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6712 throw;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6713 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6714 catch( std::exception& ex ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6715 return ex.what();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6716 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6717 catch( std::string& msg ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6718 return msg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6719 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6720 catch( const char* msg ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6721 return msg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6722 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6723 catch(...) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6724 return "Unknown exception";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6725 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6726 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6727
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6728 std::string tryTranslators() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6729 if( m_translators.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6730 throw;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6731 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6732 return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6733 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6734
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6735 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6736 std::vector<const IExceptionTranslator*> m_translators;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6737 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6738 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6739
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6740 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6741
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6742 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6743
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6744 class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6745
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6746 RegistryHub( RegistryHub const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6747 void operator=( RegistryHub const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6748
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6749 public: // IRegistryHub
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6750 RegistryHub() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6751 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6752 virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6753 return m_reporterRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6754 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6755 virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6756 return m_testCaseRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6757 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6758 virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6759 return m_exceptionTranslatorRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6760 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6761
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6762 public: // IMutableRegistryHub
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6763 virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6764 m_reporterRegistry.registerReporter( name, factory );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6765 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6766 virtual void registerListener( Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6767 m_reporterRegistry.registerListener( factory );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6768 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6769 virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6770 m_testCaseRegistry.registerTest( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6771 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6772 virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6773 m_exceptionTranslatorRegistry.registerTranslator( translator );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6774 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6775
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6776 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6777 TestRegistry m_testCaseRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6778 ReporterRegistry m_reporterRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6779 ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6780 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6781
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6782 // Single, global, instance
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6783 inline RegistryHub*& getTheRegistryHub() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6784 static RegistryHub* theRegistryHub = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6785 if( !theRegistryHub )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6786 theRegistryHub = new RegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6787 return theRegistryHub;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6788 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6789 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6790
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6791 IRegistryHub& getRegistryHub() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6792 return *getTheRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6793 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6794 IMutableRegistryHub& getMutableRegistryHub() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6795 return *getTheRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6796 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6797 void cleanUp() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6798 delete getTheRegistryHub();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6799 getTheRegistryHub() = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6800 cleanUpContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6801 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6802 std::string translateActiveException() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6803 return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6804 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6805
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6806 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6807
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6808 // #included from: catch_notimplemented_exception.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6809 #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6810
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6811 #include <ostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6812
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6813 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6814
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6815 NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6816 : m_lineInfo( lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6817 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6818 oss << lineInfo << ": function ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6819 oss << "not implemented";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6820 m_what = oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6821 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6822
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6823 const char* NotImplementedException::what() const CATCH_NOEXCEPT {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6824 return m_what.c_str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6825 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6826
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6827 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6828
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6829 // #included from: catch_context_impl.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6830 #define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6831
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6832 // #included from: catch_stream.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6833 #define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6834
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6835 #include <stdexcept>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6836 #include <cstdio>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6837 #include <iostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6838
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6839 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6840
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6841 template<typename WriterF, size_t bufferSize=256>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6842 class StreamBufImpl : public StreamBufBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6843 char data[bufferSize];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6844 WriterF m_writer;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6845
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6846 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6847 StreamBufImpl() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6848 setp( data, data + sizeof(data) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6849 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6850
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6851 ~StreamBufImpl() CATCH_NOEXCEPT {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6852 sync();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6853 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6854
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6855 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6856 int overflow( int c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6857 sync();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6858
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6859 if( c != EOF ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6860 if( pbase() == epptr() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6861 m_writer( std::string( 1, static_cast<char>( c ) ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6862 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6863 sputc( static_cast<char>( c ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6864 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6865 return 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6866 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6867
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6868 int sync() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6869 if( pbase() != pptr() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6870 m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6871 setp( pbase(), epptr() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6872 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6873 return 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6874 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6875 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6876
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6877 ///////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6878
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6879 FileStream::FileStream( std::string const& filename ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6880 m_ofs.open( filename.c_str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6881 if( m_ofs.fail() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6882 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6883 oss << "Unable to open file: '" << filename << "'";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6884 throw std::domain_error( oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6885 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6886 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6887
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6888 std::ostream& FileStream::stream() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6889 return m_ofs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6890 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6891
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6892 struct OutputDebugWriter {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6893
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6894 void operator()( std::string const&str ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6895 writeToDebugConsole( str );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6896 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6897 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6898
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6899 DebugOutStream::DebugOutStream()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6900 : m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6901 m_os( m_streamBuf.get() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6902 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6903
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6904 std::ostream& DebugOutStream::stream() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6905 return m_os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6906 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6907
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6908 // Store the streambuf from cout up-front because
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6909 // cout may get redirected when running tests
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6910 CoutStream::CoutStream()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6911 : m_os( Catch::cout().rdbuf() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6912 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6913
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6914 std::ostream& CoutStream::stream() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6915 return m_os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6916 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6917
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6918 #ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6919 std::ostream& cout() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6920 return std::cout;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6921 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6922 std::ostream& cerr() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6923 return std::cerr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6924 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6925 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6926 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6927
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6928 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6929
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6930 class Context : public IMutableContext {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6931
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6932 Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6933 Context( Context const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6934 void operator=( Context const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6935
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6936 public: // IContext
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6937 virtual IResultCapture* getResultCapture() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6938 return m_resultCapture;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6939 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6940 virtual IRunner* getRunner() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6941 return m_runner;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6942 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6943 virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6944 return getGeneratorsForCurrentTest()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6945 .getGeneratorInfo( fileInfo, totalSize )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6946 .getCurrentIndex();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6947 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6948 virtual bool advanceGeneratorsForCurrentTest() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6949 IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6950 return generators && generators->moveNext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6951 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6952
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6953 virtual Ptr<IConfig const> getConfig() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6954 return m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6955 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6956
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6957 public: // IMutableContext
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6958 virtual void setResultCapture( IResultCapture* resultCapture ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6959 m_resultCapture = resultCapture;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6960 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6961 virtual void setRunner( IRunner* runner ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6962 m_runner = runner;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6963 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6964 virtual void setConfig( Ptr<IConfig const> const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6965 m_config = config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6966 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6967
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6968 friend IMutableContext& getCurrentMutableContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6969
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6970 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6971 IGeneratorsForTest* findGeneratorsForCurrentTest() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6972 std::string testName = getResultCapture()->getCurrentTestName();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6973
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6974 std::map<std::string, IGeneratorsForTest*>::const_iterator it =
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6975 m_generatorsByTestName.find( testName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6976 return it != m_generatorsByTestName.end()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6977 ? it->second
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6978 : CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6979 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6980
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6981 IGeneratorsForTest& getGeneratorsForCurrentTest() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6982 IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6983 if( !generators ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6984 std::string testName = getResultCapture()->getCurrentTestName();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6985 generators = createGeneratorsForTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6986 m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6987 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6988 return *generators;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6989 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6990
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6991 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6992 Ptr<IConfig const> m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6993 IRunner* m_runner;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6994 IResultCapture* m_resultCapture;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6995 std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6996 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6997
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6998 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
6999 Context* currentContext = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7000 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7001 IMutableContext& getCurrentMutableContext() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7002 if( !currentContext )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7003 currentContext = new Context();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7004 return *currentContext;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7005 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7006 IContext& getCurrentContext() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7007 return getCurrentMutableContext();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7008 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7009
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7010 void cleanUpContext() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7011 delete currentContext;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7012 currentContext = CATCH_NULL;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7013 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7014 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7015
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7016 // #included from: catch_console_colour_impl.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7017 #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7018
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7019 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7020 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7021
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7022 struct IColourImpl {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7023 virtual ~IColourImpl() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7024 virtual void use( Colour::Code _colourCode ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7025 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7026
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7027 struct NoColourImpl : IColourImpl {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7028 void use( Colour::Code ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7029
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7030 static IColourImpl* instance() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7031 static NoColourImpl s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7032 return &s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7033 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7034 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7035
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7036 } // anon namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7037 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7039 #if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7040 # ifdef CATCH_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7041 # define CATCH_CONFIG_COLOUR_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7042 # else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7043 # define CATCH_CONFIG_COLOUR_ANSI
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7044 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7045 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7046
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7047 #if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) /////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7048
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7049 #ifndef NOMINMAX
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7050 #define NOMINMAX
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7051 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7052
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7053 #ifdef __AFXDLL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7054 #include <AfxWin.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7055 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7056 #include <windows.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7057 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7058
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7059 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7060 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7061
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7062 class Win32ColourImpl : public IColourImpl {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7063 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7064 Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7065 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7066 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7067 GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7068 originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7069 originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7070 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7071
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7072 virtual void use( Colour::Code _colourCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7073 switch( _colourCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7074 case Colour::None: return setTextAttribute( originalForegroundAttributes );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7075 case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7076 case Colour::Red: return setTextAttribute( FOREGROUND_RED );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7077 case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7078 case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7079 case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7080 case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7081 case Colour::Grey: return setTextAttribute( 0 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7082
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7083 case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7084 case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7085 case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7086 case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7087
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7088 case Colour::Bright: throw std::logic_error( "not a colour" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7089 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7090 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7091
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7092 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7093 void setTextAttribute( WORD _textAttribute ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7094 SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7095 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7096 HANDLE stdoutHandle;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7097 WORD originalForegroundAttributes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7098 WORD originalBackgroundAttributes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7099 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7100
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7101 IColourImpl* platformColourInstance() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7102 static Win32ColourImpl s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7103
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7104 Ptr<IConfig const> config = getCurrentContext().getConfig();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7105 UseColour::YesOrNo colourMode = config
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7106 ? config->useColour()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7107 : UseColour::Auto;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7108 if( colourMode == UseColour::Auto )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7109 colourMode = !isDebuggerActive()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7110 ? UseColour::Yes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7111 : UseColour::No;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7112 return colourMode == UseColour::Yes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7113 ? &s_instance
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7114 : NoColourImpl::instance();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7115 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7116
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7117 } // end anon namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7118 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7119
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7120 #elif defined( CATCH_CONFIG_COLOUR_ANSI ) //////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7121
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7122 #include <unistd.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7123
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7124 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7125 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7126
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7127 // use POSIX/ ANSI console terminal codes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7128 // Thanks to Adam Strzelecki for original contribution
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7129 // (http://github.com/nanoant)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7130 // https://github.com/philsquared/Catch/pull/131
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7131 class PosixColourImpl : public IColourImpl {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7132 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7133 virtual void use( Colour::Code _colourCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7134 switch( _colourCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7135 case Colour::None:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7136 case Colour::White: return setColour( "[0m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7137 case Colour::Red: return setColour( "[0;31m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7138 case Colour::Green: return setColour( "[0;32m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7139 case Colour::Blue: return setColour( "[0:34m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7140 case Colour::Cyan: return setColour( "[0;36m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7141 case Colour::Yellow: return setColour( "[0;33m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7142 case Colour::Grey: return setColour( "[1;30m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7143
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7144 case Colour::LightGrey: return setColour( "[0;37m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7145 case Colour::BrightRed: return setColour( "[1;31m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7146 case Colour::BrightGreen: return setColour( "[1;32m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7147 case Colour::BrightWhite: return setColour( "[1;37m" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7148
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7149 case Colour::Bright: throw std::logic_error( "not a colour" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7150 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7151 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7152 static IColourImpl* instance() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7153 static PosixColourImpl s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7154 return &s_instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7155 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7156
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7157 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7158 void setColour( const char* _escapeCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7159 Catch::cout() << '\033' << _escapeCode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7160 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7161 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7162
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7163 IColourImpl* platformColourInstance() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7164 Ptr<IConfig const> config = getCurrentContext().getConfig();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7165 UseColour::YesOrNo colourMode = config
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7166 ? config->useColour()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7167 : UseColour::Auto;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7168 if( colourMode == UseColour::Auto )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7169 colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7170 ? UseColour::Yes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7171 : UseColour::No;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7172 return colourMode == UseColour::Yes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7173 ? PosixColourImpl::instance()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7174 : NoColourImpl::instance();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7175 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7176
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7177 } // end anon namespace
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7178 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7179
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7180 #else // not Windows or ANSI ///////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7181
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7182 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7183
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7184 static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7185
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7186 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7187
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7188 #endif // Windows/ ANSI/ None
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7189
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7190 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7191
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7192 Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7193 Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast<Colour&>( _other ).m_moved = true; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7194 Colour::~Colour(){ if( !m_moved ) use( None ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7195
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7196 void Colour::use( Code _colourCode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7197 static IColourImpl* impl = platformColourInstance();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7198 impl->use( _colourCode );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7199 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7200
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7201 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7202
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7203 // #included from: catch_generators_impl.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7204 #define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7205
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7206 #include <vector>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7207 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7208 #include <map>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7209
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7210 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7211
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7212 struct GeneratorInfo : IGeneratorInfo {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7213
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7214 GeneratorInfo( std::size_t size )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7215 : m_size( size ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7216 m_currentIndex( 0 )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7217 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7218
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7219 bool moveNext() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7220 if( ++m_currentIndex == m_size ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7221 m_currentIndex = 0;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7222 return false;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7223 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7224 return true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7225 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7226
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7227 std::size_t getCurrentIndex() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7228 return m_currentIndex;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7229 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7230
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7231 std::size_t m_size;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7232 std::size_t m_currentIndex;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7233 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7234
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7235 ///////////////////////////////////////////////////////////////////////////
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7236
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7237 class GeneratorsForTest : public IGeneratorsForTest {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7238
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7239 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7240 ~GeneratorsForTest() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7241 deleteAll( m_generatorsInOrder );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7242 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7243
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7244 IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7245 std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7246 if( it == m_generatorsByName.end() ) {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7247 IGeneratorInfo* info = new GeneratorInfo( size );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7248 m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7249 m_generatorsInOrder.push_back( info );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7250 return *info;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7251 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7252 return *it->second;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7253 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7254
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7255 bool moveNext() {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7256 std::vector<IGeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7257 std::vector<IGeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7258 for(; it != itEnd; ++it ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7259 if( (*it)->moveNext() )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7260 return true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7261 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7262 return false;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7263 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7264
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7265 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7266 std::map<std::string, IGeneratorInfo*> m_generatorsByName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7267 std::vector<IGeneratorInfo*> m_generatorsInOrder;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7268 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7269
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7270 IGeneratorsForTest* createGeneratorsForTest()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7271 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7272 return new GeneratorsForTest();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7273 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7274
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7275 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7276
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7277 // #included from: catch_assertionresult.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7278 #define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7279
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7280 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7281
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7282 AssertionInfo::AssertionInfo( std::string const& _macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7283 SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7284 std::string const& _capturedExpression,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7285 ResultDisposition::Flags _resultDisposition )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7286 : macroName( _macroName ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7287 lineInfo( _lineInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7288 capturedExpression( _capturedExpression ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7289 resultDisposition( _resultDisposition )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7290 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7291
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7292 AssertionResult::AssertionResult() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7293
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7294 AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7295 : m_info( info ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7296 m_resultData( data )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7297 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7298
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7299 AssertionResult::~AssertionResult() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7300
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7301 // Result was a success
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7302 bool AssertionResult::succeeded() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7303 return Catch::isOk( m_resultData.resultType );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7304 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7305
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7306 // Result was a success, or failure is suppressed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7307 bool AssertionResult::isOk() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7308 return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7309 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7310
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7311 ResultWas::OfType AssertionResult::getResultType() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7312 return m_resultData.resultType;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7313 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7314
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7315 bool AssertionResult::hasExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7316 return !m_info.capturedExpression.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7317 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7318
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7319 bool AssertionResult::hasMessage() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7320 return !m_resultData.message.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7321 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7322
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7323 std::string AssertionResult::getExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7324 if( isFalseTest( m_info.resultDisposition ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7325 return "!" + m_info.capturedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7326 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7327 return m_info.capturedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7328 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7329 std::string AssertionResult::getExpressionInMacro() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7330 if( m_info.macroName.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7331 return m_info.capturedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7332 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7333 return m_info.macroName + "( " + m_info.capturedExpression + " )";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7334 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7335
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7336 bool AssertionResult::hasExpandedExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7337 return hasExpression() && getExpandedExpression() != getExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7338 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7339
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7340 std::string AssertionResult::getExpandedExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7341 return m_resultData.reconstructedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7342 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7343
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7344 std::string AssertionResult::getMessage() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7345 return m_resultData.message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7346 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7347 SourceLineInfo AssertionResult::getSourceInfo() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7348 return m_info.lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7349 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7350
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7351 std::string AssertionResult::getTestMacroName() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7352 return m_info.macroName;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7353 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7354
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7355 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7356
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7357 // #included from: catch_test_case_info.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7358 #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7359
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7360 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7361
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7362 inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7363 if( startsWith( tag, "." ) ||
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7364 tag == "hide" ||
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7365 tag == "!hide" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7366 return TestCaseInfo::IsHidden;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7367 else if( tag == "!throws" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7368 return TestCaseInfo::Throws;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7369 else if( tag == "!shouldfail" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7370 return TestCaseInfo::ShouldFail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7371 else if( tag == "!mayfail" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7372 return TestCaseInfo::MayFail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7373 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7374 return TestCaseInfo::None;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7375 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7376 inline bool isReservedTag( std::string const& tag ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7377 return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7378 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7379 inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7380 if( isReservedTag( tag ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7381 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7382 Colour colourGuard( Colour::Red );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7383 Catch::cerr()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7384 << "Tag name [" << tag << "] not allowed.\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7385 << "Tag names starting with non alpha-numeric characters are reserved\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7386 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7387 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7388 Colour colourGuard( Colour::FileName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7389 Catch::cerr() << _lineInfo << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7390 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7391 exit(1);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7392 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7393 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7394
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7395 TestCase makeTestCase( ITestCase* _testCase,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7396 std::string const& _className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7397 std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7398 std::string const& _descOrTags,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7399 SourceLineInfo const& _lineInfo )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7400 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7401 bool isHidden( startsWith( _name, "./" ) ); // Legacy support
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7402
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7403 // Parse out tags
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7404 std::set<std::string> tags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7405 std::string desc, tag;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7406 bool inTag = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7407 for( std::size_t i = 0; i < _descOrTags.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7408 char c = _descOrTags[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7409 if( !inTag ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7410 if( c == '[' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7411 inTag = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7412 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7413 desc += c;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7414 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7415 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7416 if( c == ']' ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7417 TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7418 if( prop == TestCaseInfo::IsHidden )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7419 isHidden = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7420 else if( prop == TestCaseInfo::None )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7421 enforceNotReservedTag( tag, _lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7422
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7423 tags.insert( tag );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7424 tag.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7425 inTag = false;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7426 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7427 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7428 tag += c;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7429 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7430 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7431 if( isHidden ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7432 tags.insert( "hide" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7433 tags.insert( "." );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7434 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7435
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7436 TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7437 return TestCase( _testCase, info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7438 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7439
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7440 void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7441 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7442 testCaseInfo.tags = tags;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7443 testCaseInfo.lcaseTags.clear();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7444
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7445 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7446 for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7447 oss << "[" << *it << "]";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7448 std::string lcaseTag = toLower( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7449 testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7450 testCaseInfo.lcaseTags.insert( lcaseTag );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7451 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7452 testCaseInfo.tagsAsString = oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7453 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7454
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7455 TestCaseInfo::TestCaseInfo( std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7456 std::string const& _className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7457 std::string const& _description,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7458 std::set<std::string> const& _tags,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7459 SourceLineInfo const& _lineInfo )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7460 : name( _name ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7461 className( _className ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7462 description( _description ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7463 lineInfo( _lineInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7464 properties( None )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7465 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7466 setTags( *this, _tags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7467 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7468
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7469 TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7470 : name( other.name ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7471 className( other.className ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7472 description( other.description ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7473 tags( other.tags ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7474 lcaseTags( other.lcaseTags ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7475 tagsAsString( other.tagsAsString ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7476 lineInfo( other.lineInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7477 properties( other.properties )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7478 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7479
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7480 bool TestCaseInfo::isHidden() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7481 return ( properties & IsHidden ) != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7482 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7483 bool TestCaseInfo::throws() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7484 return ( properties & Throws ) != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7485 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7486 bool TestCaseInfo::okToFail() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7487 return ( properties & (ShouldFail | MayFail ) ) != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7488 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7489 bool TestCaseInfo::expectedToFail() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7490 return ( properties & (ShouldFail ) ) != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7491 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7492
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7493 TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7494
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7495 TestCase::TestCase( TestCase const& other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7496 : TestCaseInfo( other ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7497 test( other.test )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7498 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7499
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7500 TestCase TestCase::withName( std::string const& _newName ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7501 TestCase other( *this );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7502 other.name = _newName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7503 return other;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7504 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7505
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7506 void TestCase::swap( TestCase& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7507 test.swap( other.test );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7508 name.swap( other.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7509 className.swap( other.className );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7510 description.swap( other.description );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7511 tags.swap( other.tags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7512 lcaseTags.swap( other.lcaseTags );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7513 tagsAsString.swap( other.tagsAsString );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7514 std::swap( TestCaseInfo::properties, static_cast<TestCaseInfo&>( other ).properties );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7515 std::swap( lineInfo, other.lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7516 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7517
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7518 void TestCase::invoke() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7519 test->invoke();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7520 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7521
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7522 bool TestCase::operator == ( TestCase const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7523 return test.get() == other.test.get() &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7524 name == other.name &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7525 className == other.className;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7526 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7527
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7528 bool TestCase::operator < ( TestCase const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7529 return name < other.name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7530 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7531 TestCase& TestCase::operator = ( TestCase const& other ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7532 TestCase temp( other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7533 swap( temp );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7534 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7535 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7536
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7537 TestCaseInfo const& TestCase::getTestCaseInfo() const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7538 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7539 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7540 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7541
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7542 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7543
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7544 // #included from: catch_version.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7545 #define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7546
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7547 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7548
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7549 Version::Version
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7550 ( unsigned int _majorVersion,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7551 unsigned int _minorVersion,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7552 unsigned int _patchNumber,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7553 std::string const& _branchName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7554 unsigned int _buildNumber )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7555 : majorVersion( _majorVersion ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7556 minorVersion( _minorVersion ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7557 patchNumber( _patchNumber ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7558 branchName( _branchName ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7559 buildNumber( _buildNumber )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7560 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7561
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7562 std::ostream& operator << ( std::ostream& os, Version const& version ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7563 os << version.majorVersion << "."
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7564 << version.minorVersion << "."
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7565 << version.patchNumber;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7566
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7567 if( !version.branchName.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7568 os << "-" << version.branchName
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7569 << "." << version.buildNumber;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7570 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7571 return os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7572 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7573
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7574 Version libraryVersion( 1, 5, 6, "", 0 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7575
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7576 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7577
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7578 // #included from: catch_message.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7579 #define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7580
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7581 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7582
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7583 MessageInfo::MessageInfo( std::string const& _macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7584 SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7585 ResultWas::OfType _type )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7586 : macroName( _macroName ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7587 lineInfo( _lineInfo ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7588 type( _type ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7589 sequence( ++globalCount )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7590 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7591
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7592 // This may need protecting if threading support is added
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7593 unsigned int MessageInfo::globalCount = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7594
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7595 ////////////////////////////////////////////////////////////////////////////
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7596
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7597 ScopedMessage::ScopedMessage( MessageBuilder const& builder )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7598 : m_info( builder.m_info )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7599 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7600 m_info.message = builder.m_stream.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7601 getResultCapture().pushScopedMessage( m_info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7602 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7603 ScopedMessage::ScopedMessage( ScopedMessage const& other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7604 : m_info( other.m_info )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7605 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7606
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7607 ScopedMessage::~ScopedMessage() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7608 getResultCapture().popScopedMessage( m_info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7609 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7610
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7611 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7612
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7613 // #included from: catch_legacy_reporter_adapter.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7614 #define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7615
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7616 // #included from: catch_legacy_reporter_adapter.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7617 #define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7618
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7619 namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7620 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7621 // Deprecated
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7622 struct IReporter : IShared {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7623 virtual ~IReporter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7624
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7625 virtual bool shouldRedirectStdout() const = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7626
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7627 virtual void StartTesting() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7628 virtual void EndTesting( Totals const& totals ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7629 virtual void StartGroup( std::string const& groupName ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7630 virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7631 virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7632 virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7633 virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7634 virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7635 virtual void NoAssertionsInSection( std::string const& sectionName ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7636 virtual void NoAssertionsInTestCase( std::string const& testName ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7637 virtual void Aborted() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7638 virtual void Result( AssertionResult const& result ) = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7639 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7640
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7641 class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7642 {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7643 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7644 LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7645 virtual ~LegacyReporterAdapter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7646
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7647 virtual ReporterPreferences getPreferences() const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7648 virtual void noMatchingTestCases( std::string const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7649 virtual void testRunStarting( TestRunInfo const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7650 virtual void testGroupStarting( GroupInfo const& groupInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7651 virtual void testCaseStarting( TestCaseInfo const& testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7652 virtual void sectionStarting( SectionInfo const& sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7653 virtual void assertionStarting( AssertionInfo const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7654 virtual bool assertionEnded( AssertionStats const& assertionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7655 virtual void sectionEnded( SectionStats const& sectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7656 virtual void testCaseEnded( TestCaseStats const& testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7657 virtual void testGroupEnded( TestGroupStats const& testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7658 virtual void testRunEnded( TestRunStats const& testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7659 virtual void skipTest( TestCaseInfo const& );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7660
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7661 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7662 Ptr<IReporter> m_legacyReporter;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7663 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7664 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7665
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7666 namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7667 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7668 LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7669 : m_legacyReporter( legacyReporter )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7670 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7671 LegacyReporterAdapter::~LegacyReporterAdapter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7672
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7673 ReporterPreferences LegacyReporterAdapter::getPreferences() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7674 ReporterPreferences prefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7675 prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7676 return prefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7677 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7678
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7679 void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7680 void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7681 m_legacyReporter->StartTesting();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7682 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7683 void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7684 m_legacyReporter->StartGroup( groupInfo.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7685 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7686 void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7687 m_legacyReporter->StartTestCase( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7688 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7689 void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7690 m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7691 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7692 void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7693 // Not on legacy interface
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7694 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7695
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7696 bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7697 if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7698 for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7699 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7700 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7701 if( it->type == ResultWas::Info ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7702 ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7703 rb << it->message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7704 rb.setResultType( ResultWas::Info );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7705 AssertionResult result = rb.build();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7706 m_legacyReporter->Result( result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7707 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7708 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7709 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7710 m_legacyReporter->Result( assertionStats.assertionResult );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7711 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7712 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7713 void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7714 if( sectionStats.missingAssertions )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7715 m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7716 m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7717 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7718 void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7719 m_legacyReporter->EndTestCase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7720 ( testCaseStats.testInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7721 testCaseStats.totals,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7722 testCaseStats.stdOut,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7723 testCaseStats.stdErr );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7724 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7725 void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7726 if( testGroupStats.aborting )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7727 m_legacyReporter->Aborted();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7728 m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7729 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7730 void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7731 m_legacyReporter->EndTesting( testRunStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7732 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7733 void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7734 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7735 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7736
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7737 // #included from: catch_timer.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7738
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7739 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7740 #pragma clang diagnostic push
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7741 #pragma clang diagnostic ignored "-Wc++11-long-long"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7742 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7743
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7744 #ifdef CATCH_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7745 #include <windows.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7746 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7747 #include <sys/time.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7748 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7749
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7750 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7751
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7752 namespace {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7753 #ifdef CATCH_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7754 uint64_t getCurrentTicks() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7755 static uint64_t hz=0, hzo=0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7756 if (!hz) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7757 QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7758 QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7759 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7760 uint64_t t;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7761 QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7762 return ((t-hzo)*1000000)/hz;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7763 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7764 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7765 uint64_t getCurrentTicks() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7766 timeval t;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7767 gettimeofday(&t,CATCH_NULL);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7768 return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7769 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7770 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7771 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7772
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7773 void Timer::start() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7774 m_ticks = getCurrentTicks();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7775 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7776 unsigned int Timer::getElapsedMicroseconds() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7777 return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7778 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7779 unsigned int Timer::getElapsedMilliseconds() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7780 return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7781 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7782 double Timer::getElapsedSeconds() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7783 return getElapsedMicroseconds()/1000000.0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7784 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7785
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7786 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7787
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7788 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7789 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7790 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7791 // #included from: catch_common.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7792 #define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7793
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7794 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7795
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7796 bool startsWith( std::string const& s, std::string const& prefix ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7797 return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7798 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7799 bool endsWith( std::string const& s, std::string const& suffix ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7800 return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7801 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7802 bool contains( std::string const& s, std::string const& infix ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7803 return s.find( infix ) != std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7804 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7805 void toLowerInPlace( std::string& s ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7806 std::transform( s.begin(), s.end(), s.begin(), ::tolower );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7807 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7808 std::string toLower( std::string const& s ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7809 std::string lc = s;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7810 toLowerInPlace( lc );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7811 return lc;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7812 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7813 std::string trim( std::string const& str ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7814 static char const* whitespaceChars = "\n\r\t ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7815 std::string::size_type start = str.find_first_not_of( whitespaceChars );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7816 std::string::size_type end = str.find_last_not_of( whitespaceChars );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7817
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7818 return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7819 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7820
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7821 bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7822 bool replaced = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7823 std::size_t i = str.find( replaceThis );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7824 while( i != std::string::npos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7825 replaced = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7826 str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7827 if( i < str.size()-withThis.size() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7828 i = str.find( replaceThis, i+withThis.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7829 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7830 i = std::string::npos;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7831 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7832 return replaced;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7833 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7834
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7835 pluralise::pluralise( std::size_t count, std::string const& label )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7836 : m_count( count ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7837 m_label( label )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7838 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7839
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7840 std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7841 os << pluraliser.m_count << " " << pluraliser.m_label;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7842 if( pluraliser.m_count != 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7843 os << "s";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7844 return os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7845 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7846
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7847 SourceLineInfo::SourceLineInfo() : line( 0 ){}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7848 SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7849 : file( _file ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7850 line( _line )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7851 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7852 SourceLineInfo::SourceLineInfo( SourceLineInfo const& other )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7853 : file( other.file ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7854 line( other.line )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7855 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7856 bool SourceLineInfo::empty() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7857 return file.empty();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7858 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7859 bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7860 return line == other.line && file == other.file;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7861 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7862 bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7863 return line < other.line || ( line == other.line && file < other.file );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7864 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7865
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7866 void seedRng( IConfig const& config ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7867 if( config.rngSeed() != 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7868 std::srand( config.rngSeed() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7869 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7870 unsigned int rngSeed() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7871 return getCurrentContext().getConfig()->rngSeed();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7872 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7873
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7874 std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7875 #ifndef __GNUG__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7876 os << info.file << "(" << info.line << ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7877 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7878 os << info.file << ":" << info.line;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7879 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7880 return os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7881 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7882
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7883 void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7884 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7885 oss << locationInfo << ": Internal Catch error: '" << message << "'";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7886 if( alwaysTrue() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7887 throw std::logic_error( oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7888 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7889 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7890
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7891 // #included from: catch_section.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7892 #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7893
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7894 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7895
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7896 SectionInfo::SectionInfo
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7897 ( SourceLineInfo const& _lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7898 std::string const& _name,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7899 std::string const& _description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7900 : name( _name ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7901 description( _description ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7902 lineInfo( _lineInfo )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7903 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7904
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7905 Section::Section( SectionInfo const& info )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7906 : m_info( info ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7907 m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7908 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7909 m_timer.start();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7910 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7911
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7912 Section::~Section() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7913 if( m_sectionIncluded ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7914 SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7915 if( std::uncaught_exception() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7916 getResultCapture().sectionEndedEarly( endInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7917 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7918 getResultCapture().sectionEnded( endInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7919 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7920 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7921
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7922 // This indicates whether the section should be executed or not
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7923 Section::operator bool() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7924 return m_sectionIncluded;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7925 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7926
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7927 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7928
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7929 // #included from: catch_debugger.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7930 #define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7931
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7932 #include <iostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7933
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7934 #ifdef CATCH_PLATFORM_MAC
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7935
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7936 #include <assert.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7937 #include <stdbool.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7938 #include <sys/types.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7939 #include <unistd.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7940 #include <sys/sysctl.h>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7941
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7942 namespace Catch{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7943
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7944 // The following function is taken directly from the following technical note:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7945 // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7946
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7947 // Returns true if the current process is being debugged (either
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7948 // running under the debugger or has a debugger attached post facto).
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7949 bool isDebuggerActive(){
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7950
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7951 int mib[4];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7952 struct kinfo_proc info;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7953 size_t size;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7954
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7955 // Initialize the flags so that, if sysctl fails for some bizarre
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7956 // reason, we get a predictable result.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7957
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7958 info.kp_proc.p_flag = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7959
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7960 // Initialize mib, which tells sysctl the info we want, in this case
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7961 // we're looking for information about a specific process ID.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7962
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7963 mib[0] = CTL_KERN;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7964 mib[1] = KERN_PROC;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7965 mib[2] = KERN_PROC_PID;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7966 mib[3] = getpid();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7967
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7968 // Call sysctl.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7969
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7970 size = sizeof(info);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7971 if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7972 Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7973 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7974 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7975
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7976 // We're being debugged if the P_TRACED flag is set.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7977
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7978 return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7979 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7980 } // namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7981
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7982 #elif defined(_MSC_VER)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7983 extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7984 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7985 bool isDebuggerActive() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7986 return IsDebuggerPresent() != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7987 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7988 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7989 #elif defined(__MINGW32__)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7990 extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7991 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7992 bool isDebuggerActive() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7993 return IsDebuggerPresent() != 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7994 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7995 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7996 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7997 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7998 inline bool isDebuggerActive() { return false; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
7999 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8000 #endif // Platform
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8001
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8002 #ifdef CATCH_PLATFORM_WINDOWS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8003 extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8004 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8005 void writeToDebugConsole( std::string const& text ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8006 ::OutputDebugStringA( text.c_str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8007 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8008 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8009 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8010 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8011 void writeToDebugConsole( std::string const& text ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8012 // !TBD: Need a version for Mac/ XCode and other IDEs
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8013 Catch::cout() << text;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8014 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8015 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8016 #endif // Platform
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8017
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8018 // #included from: catch_tostring.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8019 #define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8020
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8021 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8022
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8023 namespace Detail {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8024
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8025 const std::string unprintableString = "{?}";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8026
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8027 namespace {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8028 const int hexThreshold = 255;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8029
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8030 struct Endianness {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8031 enum Arch { Big, Little };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8032
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8033 static Arch which() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8034 union _{
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8035 int asInt;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8036 char asChar[sizeof (int)];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8037 } u;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8039 u.asInt = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8040 return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8041 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8042 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8043 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8044
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8045 std::string rawMemoryToString( const void *object, std::size_t size )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8046 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8047 // Reverse order for little endian architectures
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8048 int i = 0, end = static_cast<int>( size ), inc = 1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8049 if( Endianness::which() == Endianness::Little ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8050 i = end-1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8051 end = inc = -1;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8052 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8053
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8054 unsigned char const *bytes = static_cast<unsigned char const *>(object);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8055 std::ostringstream os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8056 os << "0x" << std::setfill('0') << std::hex;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8057 for( ; i != end; i += inc )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8058 os << std::setw(2) << static_cast<unsigned>(bytes[i]);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8059 return os.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8060 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8061 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8062
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8063 std::string toString( std::string const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8064 std::string s = value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8065 if( getCurrentContext().getConfig()->showInvisibles() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8066 for(size_t i = 0; i < s.size(); ++i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8067 std::string subs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8068 switch( s[i] ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8069 case '\n': subs = "\\n"; break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8070 case '\t': subs = "\\t"; break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8071 default: break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8072 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8073 if( !subs.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8074 s = s.substr( 0, i ) + subs + s.substr( i+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8075 ++i;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8076 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8077 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8078 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8079 return "\"" + s + "\"";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8080 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8081 std::string toString( std::wstring const& value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8082
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8083 std::string s;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8084 s.reserve( value.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8085 for(size_t i = 0; i < value.size(); ++i )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8086 s += value[i] <= 0xff ? static_cast<char>( value[i] ) : '?';
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8087 return Catch::toString( s );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8088 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8089
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8090 std::string toString( const char* const value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8091 return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8092 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8093
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8094 std::string toString( char* const value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8095 return Catch::toString( static_cast<const char*>( value ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8096 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8097
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8098 std::string toString( const wchar_t* const value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8099 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8100 return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8101 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8102
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8103 std::string toString( wchar_t* const value )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8104 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8105 return Catch::toString( static_cast<const wchar_t*>( value ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8106 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8107
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8108 std::string toString( int value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8109 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8110 oss << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8111 if( value > Detail::hexThreshold )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8112 oss << " (0x" << std::hex << value << ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8113 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8114 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8115
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8116 std::string toString( unsigned long value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8117 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8118 oss << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8119 if( value > Detail::hexThreshold )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8120 oss << " (0x" << std::hex << value << ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8121 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8122 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8123
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8124 std::string toString( unsigned int value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8125 return Catch::toString( static_cast<unsigned long>( value ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8126 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8127
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8128 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8129 std::string fpToString( T value, int precision ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8130 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8131 oss << std::setprecision( precision )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8132 << std::fixed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8133 << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8134 std::string d = oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8135 std::size_t i = d.find_last_not_of( '0' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8136 if( i != std::string::npos && i != d.size()-1 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8137 if( d[i] == '.' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8138 i++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8139 d = d.substr( 0, i+1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8140 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8141 return d;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8142 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8143
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8144 std::string toString( const double value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8145 return fpToString( value, 10 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8146 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8147 std::string toString( const float value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8148 return fpToString( value, 5 ) + "f";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8149 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8150
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8151 std::string toString( bool value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8152 return value ? "true" : "false";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8153 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8154
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8155 std::string toString( char value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8156 return value < ' '
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8157 ? toString( static_cast<unsigned int>( value ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8158 : Detail::makeString( value );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8159 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8160
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8161 std::string toString( signed char value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8162 return toString( static_cast<char>( value ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8163 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8164
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8165 std::string toString( unsigned char value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8166 return toString( static_cast<char>( value ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8167 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8168
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8169 #ifdef CATCH_CONFIG_CPP11_LONG_LONG
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8170 std::string toString( long long value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8171 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8172 oss << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8173 if( value > Detail::hexThreshold )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8174 oss << " (0x" << std::hex << value << ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8175 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8176 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8177 std::string toString( unsigned long long value ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8178 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8179 oss << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8180 if( value > Detail::hexThreshold )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8181 oss << " (0x" << std::hex << value << ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8182 return oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8183 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8184 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8185
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8186 #ifdef CATCH_CONFIG_CPP11_NULLPTR
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8187 std::string toString( std::nullptr_t ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8188 return "nullptr";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8189 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8190 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8191
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8192 #ifdef __OBJC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8193 std::string toString( NSString const * const& nsstring ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8194 if( !nsstring )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8195 return "nil";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8196 return "@" + toString([nsstring UTF8String]);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8197 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8198 std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8199 if( !nsstring )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8200 return "nil";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8201 return "@" + toString([nsstring UTF8String]);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8202 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8203 std::string toString( NSObject* const& nsObject ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8204 return toString( [nsObject description] );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8205 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8206 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8207
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8208 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8209
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8210 // #included from: catch_result_builder.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8211 #define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8212
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8213 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8214
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8215 std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8216 return secondArg.empty() || secondArg == "\"\""
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8217 ? capturedExpression
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8218 : capturedExpression + ", " + secondArg;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8219 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8220 ResultBuilder::ResultBuilder( char const* macroName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8221 SourceLineInfo const& lineInfo,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8222 char const* capturedExpression,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8223 ResultDisposition::Flags resultDisposition,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8224 char const* secondArg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8225 : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8226 m_shouldDebugBreak( false ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8227 m_shouldThrow( false )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8228 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8229
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8230 ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8231 m_data.resultType = result;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8232 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8233 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8234 ResultBuilder& ResultBuilder::setResultType( bool result ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8235 m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8236 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8237 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8238 ResultBuilder& ResultBuilder::setLhs( std::string const& lhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8239 m_exprComponents.lhs = lhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8240 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8241 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8242 ResultBuilder& ResultBuilder::setRhs( std::string const& rhs ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8243 m_exprComponents.rhs = rhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8244 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8245 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8246 ResultBuilder& ResultBuilder::setOp( std::string const& op ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8247 m_exprComponents.op = op;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8248 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8249 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8250
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8251 void ResultBuilder::endExpression() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8252 m_exprComponents.testFalse = isFalseTest( m_assertionInfo.resultDisposition );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8253 captureExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8254 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8255
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8256 void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8257 m_assertionInfo.resultDisposition = resultDisposition;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8258 m_stream.oss << Catch::translateActiveException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8259 captureResult( ResultWas::ThrewException );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8260 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8261
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8262 void ResultBuilder::captureResult( ResultWas::OfType resultType ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8263 setResultType( resultType );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8264 captureExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8265 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8266 void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8267 if( expectedMessage.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8268 captureExpectedException( Matchers::Impl::Generic::AllOf<std::string>() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8269 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8270 captureExpectedException( Matchers::Equals( expectedMessage ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8271 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8272
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8273 void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8274
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8275 assert( m_exprComponents.testFalse == false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8276 AssertionResultData data = m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8277 data.resultType = ResultWas::Ok;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8278 data.reconstructedExpression = m_assertionInfo.capturedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8279
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8280 std::string actualMessage = Catch::translateActiveException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8281 if( !matcher.match( actualMessage ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8282 data.resultType = ResultWas::ExpressionFailed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8283 data.reconstructedExpression = actualMessage;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8284 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8285 AssertionResult result( m_assertionInfo, data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8286 handleResult( result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8287 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8288
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8289 void ResultBuilder::captureExpression() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8290 AssertionResult result = build();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8291 handleResult( result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8292 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8293 void ResultBuilder::handleResult( AssertionResult const& result )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8294 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8295 getResultCapture().assertionEnded( result );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8296
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8297 if( !result.isOk() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8298 if( getCurrentContext().getConfig()->shouldDebugBreak() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8299 m_shouldDebugBreak = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8300 if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8301 m_shouldThrow = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8302 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8303 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8304 void ResultBuilder::react() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8305 if( m_shouldThrow )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8306 throw Catch::TestFailureException();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8307 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8308
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8309 bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8310 bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8311
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8312 AssertionResult ResultBuilder::build() const
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8313 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8314 assert( m_data.resultType != ResultWas::Unknown );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8315
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8316 AssertionResultData data = m_data;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8317
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8318 // Flip bool results if testFalse is set
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8319 if( m_exprComponents.testFalse ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8320 if( data.resultType == ResultWas::Ok )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8321 data.resultType = ResultWas::ExpressionFailed;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8322 else if( data.resultType == ResultWas::ExpressionFailed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8323 data.resultType = ResultWas::Ok;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8324 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8325
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8326 data.message = m_stream.oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8327 data.reconstructedExpression = reconstructExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8328 if( m_exprComponents.testFalse ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8329 if( m_exprComponents.op == "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8330 data.reconstructedExpression = "!" + data.reconstructedExpression;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8331 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8332 data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8333 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8334 return AssertionResult( m_assertionInfo, data );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8335 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8336 std::string ResultBuilder::reconstructExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8337 if( m_exprComponents.op == "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8338 return m_exprComponents.lhs.empty() ? m_assertionInfo.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8339 else if( m_exprComponents.op == "matches" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8340 return m_exprComponents.lhs + " " + m_exprComponents.rhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8341 else if( m_exprComponents.op != "!" ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8342 if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8343 m_exprComponents.lhs.find("\n") == std::string::npos &&
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8344 m_exprComponents.rhs.find("\n") == std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8345 return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8346 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8347 return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8348 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8349 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8350 return "{can't expand - use " + m_assertionInfo.macroName + "_FALSE( " + m_assertionInfo.capturedExpression.substr(1) + " ) instead of " + m_assertionInfo.macroName + "( " + m_assertionInfo.capturedExpression + " ) for better diagnostics}";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8351 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8352
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8353 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8354
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8355 // #included from: catch_tag_alias_registry.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8356 #define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8357
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8358 // #included from: catch_tag_alias_registry.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8359 #define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8360
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8361 #include <map>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8362
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8363 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8364
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8365 class TagAliasRegistry : public ITagAliasRegistry {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8366 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8367 virtual ~TagAliasRegistry();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8368 virtual Option<TagAlias> find( std::string const& alias ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8369 virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8370 void add( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8371 static TagAliasRegistry& get();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8372
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8373 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8374 std::map<std::string, TagAlias> m_registry;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8375 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8376
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8377 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8378
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8379 #include <map>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8380 #include <iostream>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8381
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8382 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8383
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8384 TagAliasRegistry::~TagAliasRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8385
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8386 Option<TagAlias> TagAliasRegistry::find( std::string const& alias ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8387 std::map<std::string, TagAlias>::const_iterator it = m_registry.find( alias );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8388 if( it != m_registry.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8389 return it->second;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8390 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8391 return Option<TagAlias>();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8392 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8393
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8394 std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8395 std::string expandedTestSpec = unexpandedTestSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8396 for( std::map<std::string, TagAlias>::const_iterator it = m_registry.begin(), itEnd = m_registry.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8397 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8398 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8399 std::size_t pos = expandedTestSpec.find( it->first );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8400 if( pos != std::string::npos ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8401 expandedTestSpec = expandedTestSpec.substr( 0, pos ) +
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8402 it->second.tag +
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8403 expandedTestSpec.substr( pos + it->first.size() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8404 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8405 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8406 return expandedTestSpec;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8407 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8408
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8409 void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8410
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8411 if( !startsWith( alias, "[@" ) || !endsWith( alias, "]" ) ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8412 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8413 oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8414 throw std::domain_error( oss.str().c_str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8415 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8416 if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8417 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8418 oss << "error: tag alias, \"" << alias << "\" already registered.\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8419 << "\tFirst seen at " << find(alias)->lineInfo << "\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8420 << "\tRedefined at " << lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8421 throw std::domain_error( oss.str().c_str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8422 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8423 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8424
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8425 TagAliasRegistry& TagAliasRegistry::get() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8426 static TagAliasRegistry instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8427 return instance;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8428
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8429 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8430
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8431 ITagAliasRegistry::~ITagAliasRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8432 ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8433
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8434 RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8435 try {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8436 TagAliasRegistry::get().add( alias, tag, lineInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8437 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8438 catch( std::exception& ex ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8439 Colour colourGuard( Colour::Red );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8440 Catch::cerr() << ex.what() << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8441 exit(1);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8442 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8443 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8444
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8445 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8446
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8447 // #included from: ../reporters/catch_reporter_multi.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8448 #define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8449
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8450 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8451
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8452 class MultipleReporters : public SharedImpl<IStreamingReporter> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8453 typedef std::vector<Ptr<IStreamingReporter> > Reporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8454 Reporters m_reporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8455
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8456 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8457 void add( Ptr<IStreamingReporter> const& reporter ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8458 m_reporters.push_back( reporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8459 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8460
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8461 public: // IStreamingReporter
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8462
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8463 virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8464 return m_reporters[0]->getPreferences();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8465 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8466
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8467 virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8468 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8469 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8470 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8471 (*it)->noMatchingTestCases( spec );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8472 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8473
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8474 virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8475 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8476 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8477 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8478 (*it)->testRunStarting( testRunInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8479 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8480
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8481 virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8482 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8483 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8484 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8485 (*it)->testGroupStarting( groupInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8486 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8487
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8488 virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8489 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8490 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8491 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8492 (*it)->testCaseStarting( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8493 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8494
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8495 virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8496 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8497 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8498 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8499 (*it)->sectionStarting( sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8500 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8501
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8502 virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8503 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8504 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8505 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8506 (*it)->assertionStarting( assertionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8507 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8508
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8509 // The return value indicates if the messages buffer should be cleared:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8510 virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8511 bool clearBuffer = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8512 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8513 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8514 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8515 clearBuffer |= (*it)->assertionEnded( assertionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8516 return clearBuffer;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8517 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8518
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8519 virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8520 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8521 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8522 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8523 (*it)->sectionEnded( sectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8524 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8525
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8526 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8527 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8528 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8529 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8530 (*it)->testCaseEnded( testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8531 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8532
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8533 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8534 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8535 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8536 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8537 (*it)->testGroupEnded( testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8538 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8539
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8540 virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8541 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8542 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8543 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8544 (*it)->testRunEnded( testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8545 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8546
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8547 virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8548 for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8549 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8550 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8551 (*it)->skipTest( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8552 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8553
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8554 virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8555 return this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8556 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8557
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8558 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8559
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8560 Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8561 Ptr<IStreamingReporter> resultingReporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8562
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8563 if( existingReporter ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8564 MultipleReporters* multi = existingReporter->tryAsMulti();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8565 if( !multi ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8566 multi = new MultipleReporters;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8567 resultingReporter = Ptr<IStreamingReporter>( multi );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8568 if( existingReporter )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8569 multi->add( existingReporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8570 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8571 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8572 resultingReporter = existingReporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8573 multi->add( additionalReporter );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8574 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8575 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8576 resultingReporter = additionalReporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8577
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8578 return resultingReporter;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8579 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8580
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8581 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8582
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8583 // #included from: ../reporters/catch_reporter_xml.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8584 #define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8585
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8586 // #included from: catch_reporter_bases.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8587 #define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8588
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8589 #include <cstring>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8590
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8591 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8592
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8593 struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8594
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8595 StreamingReporterBase( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8596 : m_config( _config.fullConfig() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8597 stream( _config.stream() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8598 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8599 m_reporterPrefs.shouldRedirectStdOut = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8600 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8601
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8602 virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8603 return m_reporterPrefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8604 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8605
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8606 virtual ~StreamingReporterBase() CATCH_OVERRIDE;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8607
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8608 virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8609
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8610 virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8611 currentTestRunInfo = _testRunInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8612 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8613 virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8614 currentGroupInfo = _groupInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8615 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8616
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8617 virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8618 currentTestCaseInfo = _testInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8619 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8620 virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8621 m_sectionStack.push_back( _sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8622 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8623
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8624 virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8625 m_sectionStack.pop_back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8626 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8627 virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8628 currentTestCaseInfo.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8629 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8630 virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8631 currentGroupInfo.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8632 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8633 virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8634 currentTestCaseInfo.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8635 currentGroupInfo.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8636 currentTestRunInfo.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8637 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8638
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8639 virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8640 // Don't do anything with this by default.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8641 // It can optionally be overridden in the derived class.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8642 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8643
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8644 Ptr<IConfig const> m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8645 std::ostream& stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8646
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8647 LazyStat<TestRunInfo> currentTestRunInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8648 LazyStat<GroupInfo> currentGroupInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8649 LazyStat<TestCaseInfo> currentTestCaseInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8650
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8651 std::vector<SectionInfo> m_sectionStack;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8652 ReporterPreferences m_reporterPrefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8653 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8654
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8655 struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8656 template<typename T, typename ChildNodeT>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8657 struct Node : SharedImpl<> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8658 explicit Node( T const& _value ) : value( _value ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8659 virtual ~Node() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8660
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8661 typedef std::vector<Ptr<ChildNodeT> > ChildNodes;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8662 T value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8663 ChildNodes children;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8664 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8665 struct SectionNode : SharedImpl<> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8666 explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8667 virtual ~SectionNode();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8668
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8669 bool operator == ( SectionNode const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8670 return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8671 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8672 bool operator == ( Ptr<SectionNode> const& other ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8673 return operator==( *other );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8674 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8675
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8676 SectionStats stats;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8677 typedef std::vector<Ptr<SectionNode> > ChildSections;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8678 typedef std::vector<AssertionStats> Assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8679 ChildSections childSections;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8680 Assertions assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8681 std::string stdOut;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8682 std::string stdErr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8683 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8684
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8685 struct BySectionInfo {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8686 BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8687 BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8688 bool operator() ( Ptr<SectionNode> const& node ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8689 return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8690 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8691 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8692 void operator=( BySectionInfo const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8693 SectionInfo const& m_other;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8694 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8695
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8696 typedef Node<TestCaseStats, SectionNode> TestCaseNode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8697 typedef Node<TestGroupStats, TestCaseNode> TestGroupNode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8698 typedef Node<TestRunStats, TestGroupNode> TestRunNode;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8699
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8700 CumulativeReporterBase( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8701 : m_config( _config.fullConfig() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8702 stream( _config.stream() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8703 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8704 m_reporterPrefs.shouldRedirectStdOut = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8705 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8706 ~CumulativeReporterBase();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8707
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8708 virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8709 return m_reporterPrefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8710 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8711
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8712 virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8713 virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8714
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8715 virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8716
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8717 virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8718 SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8719 Ptr<SectionNode> node;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8720 if( m_sectionStack.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8721 if( !m_rootSection )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8722 m_rootSection = new SectionNode( incompleteStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8723 node = m_rootSection;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8724 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8725 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8726 SectionNode& parentNode = *m_sectionStack.back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8727 SectionNode::ChildSections::const_iterator it =
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8728 std::find_if( parentNode.childSections.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8729 parentNode.childSections.end(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8730 BySectionInfo( sectionInfo ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8731 if( it == parentNode.childSections.end() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8732 node = new SectionNode( incompleteStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8733 parentNode.childSections.push_back( node );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8734 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8735 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8736 node = *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8737 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8738 m_sectionStack.push_back( node );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8739 m_deepestSection = node;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8740 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8741
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8742 virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8743
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8744 virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8745 assert( !m_sectionStack.empty() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8746 SectionNode& sectionNode = *m_sectionStack.back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8747 sectionNode.assertions.push_back( assertionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8748 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8749 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8750 virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8751 assert( !m_sectionStack.empty() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8752 SectionNode& node = *m_sectionStack.back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8753 node.stats = sectionStats;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8754 m_sectionStack.pop_back();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8755 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8756 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8757 Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8758 assert( m_sectionStack.size() == 0 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8759 node->children.push_back( m_rootSection );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8760 m_testCases.push_back( node );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8761 m_rootSection.reset();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8762
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8763 assert( m_deepestSection );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8764 m_deepestSection->stdOut = testCaseStats.stdOut;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8765 m_deepestSection->stdErr = testCaseStats.stdErr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8766 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8767 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8768 Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8769 node->children.swap( m_testCases );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8770 m_testGroups.push_back( node );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8771 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8772 virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8773 Ptr<TestRunNode> node = new TestRunNode( testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8774 node->children.swap( m_testGroups );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8775 m_testRuns.push_back( node );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8776 testRunEndedCumulative();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8777 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8778 virtual void testRunEndedCumulative() = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8779
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8780 virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8781
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8782 Ptr<IConfig const> m_config;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8783 std::ostream& stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8784 std::vector<AssertionStats> m_assertions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8785 std::vector<std::vector<Ptr<SectionNode> > > m_sections;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8786 std::vector<Ptr<TestCaseNode> > m_testCases;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8787 std::vector<Ptr<TestGroupNode> > m_testGroups;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8788
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8789 std::vector<Ptr<TestRunNode> > m_testRuns;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8790
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8791 Ptr<SectionNode> m_rootSection;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8792 Ptr<SectionNode> m_deepestSection;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8793 std::vector<Ptr<SectionNode> > m_sectionStack;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8794 ReporterPreferences m_reporterPrefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8795
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8796 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8797
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8798 template<char C>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8799 char const* getLineOfChars() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8800 static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8801 if( !*line ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8802 memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8803 line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8804 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8805 return line;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8806 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8807
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8808 struct TestEventListenerBase : StreamingReporterBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8809 TestEventListenerBase( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8810 : StreamingReporterBase( _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8811 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8812
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8813 virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8814 virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8815 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8816 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8817 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8818
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8819 } // end namespace Catch
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8820
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8821 // #included from: ../internal/catch_reporter_registrars.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8822 #define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8823
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8824 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8825
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8826 template<typename T>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8827 class LegacyReporterRegistrar {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8828
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8829 class ReporterFactory : public IReporterFactory {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8830 virtual IStreamingReporter* create( ReporterConfig const& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8831 return new LegacyReporterAdapter( new T( config ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8832 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8833
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8834 virtual std::string getDescription() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8835 return T::getDescription();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8836 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8837 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8838
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8839 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8840
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8841 LegacyReporterRegistrar( std::string const& name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8842 getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8843 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8844 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8845
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8846 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8847 class ReporterRegistrar {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8848
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8849 class ReporterFactory : public SharedImpl<IReporterFactory> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8850
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8851 // *** Please Note ***:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8852 // - If you end up here looking at a compiler error because it's trying to register
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8853 // your custom reporter class be aware that the native reporter interface has changed
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8854 // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8855 // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8856 // However please consider updating to the new interface as the old one is now
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8857 // deprecated and will probably be removed quite soon!
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8858 // Please contact me via github if you have any questions at all about this.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8859 // In fact, ideally, please contact me anyway to let me know you've hit this - as I have
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8860 // no idea who is actually using custom reporters at all (possibly no-one!).
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8861 // The new interface is designed to minimise exposure to interface changes in the future.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8862 virtual IStreamingReporter* create( ReporterConfig const& config ) const {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8863 return new T( config );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8864 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8865
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8866 virtual std::string getDescription() const {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8867 return T::getDescription();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8868 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8869 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8870
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8871 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8872
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8873 ReporterRegistrar( std::string const& name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8874 getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8875 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8876 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8877
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8878 template<typename T>
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8879 class ListenerRegistrar {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8880
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8881 class ListenerFactory : public SharedImpl<IReporterFactory> {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8882
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8883 virtual IStreamingReporter* create( ReporterConfig const& config ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8884 return new T( config );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8885 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8886 virtual std::string getDescription() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8887 return "";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8888 }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8889 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8890
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8891 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8892
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8893 ListenerRegistrar() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8894 getMutableRegistryHub().registerListener( new ListenerFactory() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8895 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8896 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8897 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8898
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8899 #define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8900 namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8901
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8902 #define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8903 namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8904
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8905 #define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8906 namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8907
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8908 // #included from: ../internal/catch_xmlwriter.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8909 #define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8910
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8911 #include <sstream>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8912 #include <string>
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8913 #include <vector>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8914 #include <iomanip>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8915
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8916 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8917
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8918 class XmlEncode {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8919 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8920 enum ForWhat { ForTextNodes, ForAttributes };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8921
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8922 XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8923 : m_str( str ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8924 m_forWhat( forWhat )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8925 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8926
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8927 void encodeTo( std::ostream& os ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8928
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8929 // Apostrophe escaping not necessary if we always use " to write attributes
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8930 // (see: http://www.w3.org/TR/xml/#syntax)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8931
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8932 for( std::size_t i = 0; i < m_str.size(); ++ i ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8933 char c = m_str[i];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8934 switch( c ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8935 case '<': os << "&lt;"; break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8936 case '&': os << "&amp;"; break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8937
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8938 case '>':
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8939 // See: http://www.w3.org/TR/xml/#syntax
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8940 if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8941 os << "&gt;";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8942 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8943 os << c;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8944 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8945
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8946 case '\"':
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8947 if( m_forWhat == ForAttributes )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8948 os << "&quot;";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8949 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8950 os << c;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8951 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8952
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8953 default:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8954 // Escape control chars - based on contribution by @espenalb in PR #465
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8955 if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8956 os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8957 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8958 os << c;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8959 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8960 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8961 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8962
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8963 friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8964 xmlEncode.encodeTo( os );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8965 return os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8966 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8967
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8968 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8969 std::string m_str;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8970 ForWhat m_forWhat;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8971 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8972
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8973 class XmlWriter {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8974 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8975
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8976 class ScopedElement {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8977 public:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8978 ScopedElement( XmlWriter* writer )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8979 : m_writer( writer )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8980 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8981
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8982 ScopedElement( ScopedElement const& other )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8983 : m_writer( other.m_writer ){
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8984 other.m_writer = CATCH_NULL;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8985 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8986
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8987 ~ScopedElement() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8988 if( m_writer )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8989 m_writer->endElement();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8990 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8991
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8992 ScopedElement& writeText( std::string const& text, bool indent = true ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8993 m_writer->writeText( text, indent );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8994 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8995 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8996
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8997 template<typename T>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
8998 ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8999 m_writer->writeAttribute( name, attribute );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9000 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9001 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9002
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9003 private:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9004 mutable XmlWriter* m_writer;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9005 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9006
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9007 XmlWriter()
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9008 : m_tagIsOpen( false ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9009 m_needsNewline( false ),
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9010 m_os( &Catch::cout() )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9011 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9012
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9013 XmlWriter( std::ostream& os )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9014 : m_tagIsOpen( false ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9015 m_needsNewline( false ),
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9016 m_os( &os )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9017 {}
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9018
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9019 ~XmlWriter() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9020 while( !m_tags.empty() )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9021 endElement();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9022 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9023
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9024 XmlWriter& startElement( std::string const& name ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9025 ensureTagClosed();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9026 newlineIfNecessary();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9027 stream() << m_indent << "<" << name;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9028 m_tags.push_back( name );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9029 m_indent += " ";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9030 m_tagIsOpen = true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9031 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9032 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9033
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9034 ScopedElement scopedElement( std::string const& name ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9035 ScopedElement scoped( this );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9036 startElement( name );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9037 return scoped;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9038 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9039
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9040 XmlWriter& endElement() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9041 newlineIfNecessary();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9042 m_indent = m_indent.substr( 0, m_indent.size()-2 );
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9043 if( m_tagIsOpen ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9044 stream() << "/>\n";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9045 m_tagIsOpen = false;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9046 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9047 else {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9048 stream() << m_indent << "</" << m_tags.back() << ">\n";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9049 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9050 m_tags.pop_back();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9051 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9052 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9053
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9054 XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9055 if( !name.empty() && !attribute.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9056 stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9057 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9058 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9059
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9060 XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9061 stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9062 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9063 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9064
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9065 template<typename T>
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9066 XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9067 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9068 oss << attribute;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9069 return writeAttribute( name, oss.str() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9070 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9071
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9072 XmlWriter& writeText( std::string const& text, bool indent = true ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9073 if( !text.empty() ){
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9074 bool tagWasOpen = m_tagIsOpen;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9075 ensureTagClosed();
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9076 if( tagWasOpen && indent )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9077 stream() << m_indent;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9078 stream() << XmlEncode( text );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9079 m_needsNewline = true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9080 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9081 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9082 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9083
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9084 XmlWriter& writeComment( std::string const& text ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9085 ensureTagClosed();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9086 stream() << m_indent << "<!--" << text << "-->";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9087 m_needsNewline = true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9088 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9089 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9090
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9091 XmlWriter& writeBlankLine() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9092 ensureTagClosed();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9093 stream() << "\n";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9094 return *this;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9095 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9096
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9097 void setStream( std::ostream& os ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9098 m_os = &os;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9099 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9100
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9101 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9102 XmlWriter( XmlWriter const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9103 void operator=( XmlWriter const& );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9104
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9105 std::ostream& stream() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9106 return *m_os;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9107 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9108
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9109 void ensureTagClosed() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9110 if( m_tagIsOpen ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9111 stream() << ">\n";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9112 m_tagIsOpen = false;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9113 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9114 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9115
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9116 void newlineIfNecessary() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9117 if( m_needsNewline ) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9118 stream() << "\n";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9119 m_needsNewline = false;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9120 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9121 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9122
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9123 bool m_tagIsOpen;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9124 bool m_needsNewline;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9125 std::vector<std::string> m_tags;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9126 std::string m_indent;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9127 std::ostream* m_os;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9128 };
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9129
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9130 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9131 // #included from: catch_reenable_warnings.h
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9132
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9133 #define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9134
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9135 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9136 # ifdef __ICC // icpc defines the __clang__ macro
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9137 # pragma warning(pop)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9138 # else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9139 # pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9140 # endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9141 #elif defined __GNUC__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9142 # pragma GCC diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9143 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9144
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9145
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9146 namespace Catch {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9147 class XmlReporter : public StreamingReporterBase {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9148 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9149 XmlReporter( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9150 : StreamingReporterBase( _config ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9151 m_sectionDepth( 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9152 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9153 m_reporterPrefs.shouldRedirectStdOut = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9154 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9155
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9156 virtual ~XmlReporter() CATCH_OVERRIDE;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9157
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9158 static std::string getDescription() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9159 return "Reports test results as an XML document";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9160 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9161
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9162 public: // StreamingReporterBase
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9163
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9164 virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9165 StreamingReporterBase::noMatchingTestCases( s );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9166 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9167
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9168 virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9169 StreamingReporterBase::testRunStarting( testInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9170 m_xml.setStream( stream );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9171 m_xml.startElement( "Catch" );
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9172 if( !m_config->name().empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9173 m_xml.writeAttribute( "name", m_config->name() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9174 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9175
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9176 virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9177 StreamingReporterBase::testGroupStarting( groupInfo );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9178 m_xml.startElement( "Group" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9179 .writeAttribute( "name", groupInfo.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9180 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9181
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9182 virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9183 StreamingReporterBase::testCaseStarting(testInfo);
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9184 m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9185
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9186 if ( m_config->showDurations() == ShowDurations::Always )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9187 m_testCaseTimer.start();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9188 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9189
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9190 virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9191 StreamingReporterBase::sectionStarting( sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9192 if( m_sectionDepth++ > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9193 m_xml.startElement( "Section" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9194 .writeAttribute( "name", trim( sectionInfo.name ) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9195 .writeAttribute( "description", sectionInfo.description );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9196 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9197 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9198
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9199 virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9200
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9201 virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9202 const AssertionResult& assertionResult = assertionStats.assertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9203
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9204 // Print any info messages in <Info> tags.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9205 if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9206 for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9207 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9208 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9209 if( it->type == ResultWas::Info ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9210 m_xml.scopedElement( "Info" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9211 .writeText( it->message );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9212 } else if ( it->type == ResultWas::Warning ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9213 m_xml.scopedElement( "Warning" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9214 .writeText( it->message );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9215 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9216 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9217 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9218
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9219 // Drop out if result was successful but we're not printing them.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9220 if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9221 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9222
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9223 // Print the expression if there is one.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9224 if( assertionResult.hasExpression() ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9225 m_xml.startElement( "Expression" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9226 .writeAttribute( "success", assertionResult.succeeded() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9227 .writeAttribute( "type", assertionResult.getTestMacroName() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9228 .writeAttribute( "filename", assertionResult.getSourceInfo().file )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9229 .writeAttribute( "line", assertionResult.getSourceInfo().line );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9230
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9231 m_xml.scopedElement( "Original" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9232 .writeText( assertionResult.getExpression() );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9233 m_xml.scopedElement( "Expanded" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9234 .writeText( assertionResult.getExpandedExpression() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9235 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9236
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9237 // And... Print a result applicable to each result type.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9238 switch( assertionResult.getResultType() ) {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9239 case ResultWas::ThrewException:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9240 m_xml.scopedElement( "Exception" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9241 .writeAttribute( "filename", assertionResult.getSourceInfo().file )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9242 .writeAttribute( "line", assertionResult.getSourceInfo().line )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9243 .writeText( assertionResult.getMessage() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9244 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9245 case ResultWas::FatalErrorCondition:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9246 m_xml.scopedElement( "Fatal Error Condition" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9247 .writeAttribute( "filename", assertionResult.getSourceInfo().file )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9248 .writeAttribute( "line", assertionResult.getSourceInfo().line )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9249 .writeText( assertionResult.getMessage() );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9250 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9251 case ResultWas::Info:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9252 m_xml.scopedElement( "Info" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9253 .writeText( assertionResult.getMessage() );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9254 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9255 case ResultWas::Warning:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9256 // Warning will already have been written
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9257 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9258 case ResultWas::ExplicitFailure:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9259 m_xml.scopedElement( "Failure" )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9260 .writeText( assertionResult.getMessage() );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9261 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9262 default:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9263 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9264 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9265
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9266 if( assertionResult.hasExpression() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9267 m_xml.endElement();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9268
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9269 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9270 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9271
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9272 virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9273 StreamingReporterBase::sectionEnded( sectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9274 if( --m_sectionDepth > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9275 XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9276 e.writeAttribute( "successes", sectionStats.assertions.passed );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9277 e.writeAttribute( "failures", sectionStats.assertions.failed );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9278 e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9279
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9280 if ( m_config->showDurations() == ShowDurations::Always )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9281 e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9282
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9283 m_xml.endElement();
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9284 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9285 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9286
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9287 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9288 StreamingReporterBase::testCaseEnded( testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9289 XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9290 e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9291
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9292 if ( m_config->showDurations() == ShowDurations::Always )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9293 e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9294
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9295 m_xml.endElement();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9296 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9297
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9298 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9299 StreamingReporterBase::testGroupEnded( testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9300 // TODO: Check testGroupStats.aborting and act accordingly.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9301 m_xml.scopedElement( "OverallResults" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9302 .writeAttribute( "successes", testGroupStats.totals.assertions.passed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9303 .writeAttribute( "failures", testGroupStats.totals.assertions.failed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9304 .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9305 m_xml.endElement();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9306 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9307
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9308 virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9309 StreamingReporterBase::testRunEnded( testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9310 m_xml.scopedElement( "OverallResults" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9311 .writeAttribute( "successes", testRunStats.totals.assertions.passed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9312 .writeAttribute( "failures", testRunStats.totals.assertions.failed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9313 .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9314 m_xml.endElement();
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9315 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9316
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9317 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9318 Timer m_testCaseTimer;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9319 XmlWriter m_xml;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9320 int m_sectionDepth;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9321 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9322
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9323 INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9324
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9325 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9326
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9327 // #included from: ../reporters/catch_reporter_junit.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9328 #define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9329
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9330 #include <assert.h>
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9331
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9332 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9333
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9334 class JunitReporter : public CumulativeReporterBase {
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9335 public:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9336 JunitReporter( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9337 : CumulativeReporterBase( _config ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9338 xml( _config.stream() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9339 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9340 m_reporterPrefs.shouldRedirectStdOut = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9341 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9342
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9343 virtual ~JunitReporter() CATCH_OVERRIDE;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9344
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9345 static std::string getDescription() {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9346 return "Reports test results in an XML format that looks like Ant's junitreport target";
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9347 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9348
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9349 virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9350
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9351 virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9352 CumulativeReporterBase::testRunStarting( runInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9353 xml.startElement( "testsuites" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9354 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9355
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9356 virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9357 suiteTimer.start();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9358 stdOutForSuite.str("");
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9359 stdErrForSuite.str("");
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9360 unexpectedExceptions = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9361 CumulativeReporterBase::testGroupStarting( groupInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9362 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9363
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9364 virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9365 if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9366 unexpectedExceptions++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9367 return CumulativeReporterBase::assertionEnded( assertionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9368 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9369
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9370 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9371 stdOutForSuite << testCaseStats.stdOut;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9372 stdErrForSuite << testCaseStats.stdErr;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9373 CumulativeReporterBase::testCaseEnded( testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9374 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9375
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9376 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9377 double suiteTime = suiteTimer.getElapsedSeconds();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9378 CumulativeReporterBase::testGroupEnded( testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9379 writeGroup( *m_testGroups.back(), suiteTime );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9380 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9381
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9382 virtual void testRunEndedCumulative() CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9383 xml.endElement();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9384 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9385
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9386 void writeGroup( TestGroupNode const& groupNode, double suiteTime ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9387 XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9388 TestGroupStats const& stats = groupNode.value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9389 xml.writeAttribute( "name", stats.groupInfo.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9390 xml.writeAttribute( "errors", unexpectedExceptions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9391 xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9392 xml.writeAttribute( "tests", stats.totals.assertions.total() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9393 xml.writeAttribute( "hostname", "tbd" ); // !TBD
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9394 if( m_config->showDurations() == ShowDurations::Never )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9395 xml.writeAttribute( "time", "" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9396 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9397 xml.writeAttribute( "time", suiteTime );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9398 xml.writeAttribute( "timestamp", "tbd" ); // !TBD
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9399
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9400 // Write test cases
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9401 for( TestGroupNode::ChildNodes::const_iterator
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9402 it = groupNode.children.begin(), itEnd = groupNode.children.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9403 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9404 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9405 writeTestCase( **it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9406
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9407 xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9408 xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9409 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9410
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9411 void writeTestCase( TestCaseNode const& testCaseNode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9412 TestCaseStats const& stats = testCaseNode.value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9413
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9414 // All test cases have exactly one section - which represents the
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9415 // test case itself. That section may have 0-n nested sections
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9416 assert( testCaseNode.children.size() == 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9417 SectionNode const& rootSection = *testCaseNode.children.front();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9418
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9419 std::string className = stats.testInfo.className;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9420
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9421 if( className.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9422 if( rootSection.childSections.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9423 className = "global";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9424 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9425 writeSection( className, "", rootSection );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9426 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9427
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9428 void writeSection( std::string const& className,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9429 std::string const& rootName,
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9430 SectionNode const& sectionNode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9431 std::string name = trim( sectionNode.stats.sectionInfo.name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9432 if( !rootName.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9433 name = rootName + "/" + name;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9434
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9435 if( !sectionNode.assertions.empty() ||
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9436 !sectionNode.stdOut.empty() ||
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9437 !sectionNode.stdErr.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9438 XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9439 if( className.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9440 xml.writeAttribute( "classname", name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9441 xml.writeAttribute( "name", "root" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9442 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9443 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9444 xml.writeAttribute( "classname", className );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9445 xml.writeAttribute( "name", name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9446 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9447 xml.writeAttribute( "time", Catch::toString( sectionNode.stats.durationInSeconds ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9448
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9449 writeAssertions( sectionNode );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9450
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9451 if( !sectionNode.stdOut.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9452 xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9453 if( !sectionNode.stdErr.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9454 xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9455 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9456 for( SectionNode::ChildSections::const_iterator
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9457 it = sectionNode.childSections.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9458 itEnd = sectionNode.childSections.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9459 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9460 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9461 if( className.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9462 writeSection( name, "", **it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9463 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9464 writeSection( className, name, **it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9465 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9466
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9467 void writeAssertions( SectionNode const& sectionNode ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9468 for( SectionNode::Assertions::const_iterator
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9469 it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9470 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9471 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9472 writeAssertion( *it );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9473 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9474 void writeAssertion( AssertionStats const& stats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9475 AssertionResult const& result = stats.assertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9476 if( !result.isOk() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9477 std::string elementName;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9478 switch( result.getResultType() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9479 case ResultWas::ThrewException:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9480 case ResultWas::FatalErrorCondition:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9481 elementName = "error";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9482 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9483 case ResultWas::ExplicitFailure:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9484 elementName = "failure";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9485 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9486 case ResultWas::ExpressionFailed:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9487 elementName = "failure";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9488 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9489 case ResultWas::DidntThrowException:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9490 elementName = "failure";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9491 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9492
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9493 // We should never see these here:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9494 case ResultWas::Info:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9495 case ResultWas::Warning:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9496 case ResultWas::Ok:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9497 case ResultWas::Unknown:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9498 case ResultWas::FailureBit:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9499 case ResultWas::Exception:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9500 elementName = "internalError";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9501 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9502 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9503
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9504 XmlWriter::ScopedElement e = xml.scopedElement( elementName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9505
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9506 xml.writeAttribute( "message", result.getExpandedExpression() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9507 xml.writeAttribute( "type", result.getTestMacroName() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9508
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9509 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9510 if( !result.getMessage().empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9511 oss << result.getMessage() << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9512 for( std::vector<MessageInfo>::const_iterator
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9513 it = stats.infoMessages.begin(),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9514 itEnd = stats.infoMessages.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9515 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9516 ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9517 if( it->type == ResultWas::Info )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9518 oss << it->message << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9519
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9520 oss << "at " << result.getSourceInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9521 xml.writeText( oss.str(), false );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9522 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9523 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9524
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9525 XmlWriter xml;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9526 Timer suiteTimer;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9527 std::ostringstream stdOutForSuite;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9528 std::ostringstream stdErrForSuite;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9529 unsigned int unexpectedExceptions;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9530 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9531
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9532 INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9533
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9534 } // end namespace Catch
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9535
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9536 // #included from: ../reporters/catch_reporter_console.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9537 #define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9538
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9539 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9540
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9541 struct ConsoleReporter : StreamingReporterBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9542 ConsoleReporter( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9543 : StreamingReporterBase( _config ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9544 m_headerPrinted( false )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9545 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9546
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9547 virtual ~ConsoleReporter() CATCH_OVERRIDE;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9548 static std::string getDescription() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9549 return "Reports test results as plain lines of text";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9550 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9551
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9552 virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9553 stream << "No test cases matched '" << spec << "'" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9554 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9555
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9556 virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9557 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9558
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9559 virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9560 AssertionResult const& result = _assertionStats.assertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9561
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9562 bool printInfoMessages = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9563
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9564 // Drop out if result was successful and we're not printing those
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9565 if( !m_config->includeSuccessfulResults() && result.isOk() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9566 if( result.getResultType() != ResultWas::Warning )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9567 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9568 printInfoMessages = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9569 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9570
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9571 lazyPrint();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9572
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9573 AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9574 printer.print();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9575 stream << std::endl;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9576 return true;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9577 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9578
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9579 virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9580 m_headerPrinted = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9581 StreamingReporterBase::sectionStarting( _sectionInfo );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9582 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9583 virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9584 if( _sectionStats.missingAssertions ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9585 lazyPrint();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9586 Colour colour( Colour::ResultError );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9587 if( m_sectionStack.size() > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9588 stream << "\nNo assertions in section";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9589 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9590 stream << "\nNo assertions in test case";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9591 stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9592 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9593 if( m_headerPrinted ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9594 if( m_config->showDurations() == ShowDurations::Always )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9595 stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9596 m_headerPrinted = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9597 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9598 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9599 if( m_config->showDurations() == ShowDurations::Always )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9600 stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9601 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9602 StreamingReporterBase::sectionEnded( _sectionStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9603 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9604
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9605 virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9606 StreamingReporterBase::testCaseEnded( _testCaseStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9607 m_headerPrinted = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9608 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9609 virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9610 if( currentGroupInfo.used ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9611 printSummaryDivider();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9612 stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9613 printTotals( _testGroupStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9614 stream << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9615 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9616 StreamingReporterBase::testGroupEnded( _testGroupStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9617 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9618 virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9619 printTotalsDivider( _testRunStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9620 printTotals( _testRunStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9621 stream << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9622 StreamingReporterBase::testRunEnded( _testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9623 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9624
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9625 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9626
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9627 class AssertionPrinter {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9628 void operator= ( AssertionPrinter const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9629 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9630 AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9631 : stream( _stream ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9632 stats( _stats ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9633 result( _stats.assertionResult ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9634 colour( Colour::None ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9635 message( result.getMessage() ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9636 messages( _stats.infoMessages ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9637 printInfoMessages( _printInfoMessages )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9638 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9639 switch( result.getResultType() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9640 case ResultWas::Ok:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9641 colour = Colour::Success;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9642 passOrFail = "PASSED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9643 //if( result.hasMessage() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9644 if( _stats.infoMessages.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9645 messageLabel = "with message";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9646 if( _stats.infoMessages.size() > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9647 messageLabel = "with messages";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9648 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9649 case ResultWas::ExpressionFailed:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9650 if( result.isOk() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9651 colour = Colour::Success;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9652 passOrFail = "FAILED - but was ok";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9653 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9654 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9655 colour = Colour::Error;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9656 passOrFail = "FAILED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9657 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9658 if( _stats.infoMessages.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9659 messageLabel = "with message";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9660 if( _stats.infoMessages.size() > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9661 messageLabel = "with messages";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9662 break;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9663 case ResultWas::ThrewException:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9664 colour = Colour::Error;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9665 passOrFail = "FAILED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9666 messageLabel = "due to unexpected exception with message";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9667 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9668 case ResultWas::FatalErrorCondition:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9669 colour = Colour::Error;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9670 passOrFail = "FAILED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9671 messageLabel = "due to a fatal error condition";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9672 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9673 case ResultWas::DidntThrowException:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9674 colour = Colour::Error;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9675 passOrFail = "FAILED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9676 messageLabel = "because no exception was thrown where one was expected";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9677 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9678 case ResultWas::Info:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9679 messageLabel = "info";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9680 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9681 case ResultWas::Warning:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9682 messageLabel = "warning";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9683 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9684 case ResultWas::ExplicitFailure:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9685 passOrFail = "FAILED";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9686 colour = Colour::Error;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9687 if( _stats.infoMessages.size() == 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9688 messageLabel = "explicitly with message";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9689 if( _stats.infoMessages.size() > 1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9690 messageLabel = "explicitly with messages";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9691 break;
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9692 // These cases are here to prevent compiler warnings
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9693 case ResultWas::Unknown:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9694 case ResultWas::FailureBit:
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9695 case ResultWas::Exception:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9696 passOrFail = "** internal error **";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9697 colour = Colour::Error;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9698 break;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9699 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9700 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9701
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9702 void print() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9703 printSourceInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9704 if( stats.totals.assertions.total() > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9705 if( result.isOk() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9706 stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9707 printResultType();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9708 printOriginalExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9709 printReconstructedExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9710 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9711 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9712 stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9713 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9714 printMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9715 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9716
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9717 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9718 void printResultType() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9719 if( !passOrFail.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9720 Colour colourGuard( colour );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9721 stream << passOrFail << ":\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9722 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9723 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9724 void printOriginalExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9725 if( result.hasExpression() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9726 Colour colourGuard( Colour::OriginalExpression );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9727 stream << " ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9728 stream << result.getExpressionInMacro();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9729 stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9730 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9731 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9732 void printReconstructedExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9733 if( result.hasExpandedExpression() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9734 stream << "with expansion:\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9735 Colour colourGuard( Colour::ReconstructedExpression );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9736 stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9737 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9738 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9739 void printMessage() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9740 if( !messageLabel.empty() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9741 stream << messageLabel << ":" << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9742 for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9743 it != itEnd;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9744 ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9745 // If this assertion is a warning ignore any INFO messages
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9746 if( printInfoMessages || it->type != ResultWas::Info )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9747 stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9748 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9749 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9750 void printSourceInfo() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9751 Colour colourGuard( Colour::FileName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9752 stream << result.getSourceInfo() << ": ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9753 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9754
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9755 std::ostream& stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9756 AssertionStats const& stats;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9757 AssertionResult const& result;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9758 Colour::Code colour;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9759 std::string passOrFail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9760 std::string messageLabel;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9761 std::string message;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9762 std::vector<MessageInfo> messages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9763 bool printInfoMessages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9764 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9765
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9766 void lazyPrint() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9767
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9768 if( !currentTestRunInfo.used )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9769 lazyPrintRunInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9770 if( !currentGroupInfo.used )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9771 lazyPrintGroupInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9772
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9773 if( !m_headerPrinted ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9774 printTestCaseAndSectionHeader();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9775 m_headerPrinted = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9776 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9777 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9778 void lazyPrintRunInfo() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9779 stream << "\n" << getLineOfChars<'~'>() << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9780 Colour colour( Colour::SecondaryText );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9781 stream << currentTestRunInfo->name
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9782 << " is a Catch v" << libraryVersion << " host application.\n"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9783 << "Run with -? for options\n\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9784
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9785 if( m_config->rngSeed() != 0 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9786 stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9787
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9788 currentTestRunInfo.used = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9789 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9790 void lazyPrintGroupInfo() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9791 if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9792 printClosedHeader( "Group: " + currentGroupInfo->name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9793 currentGroupInfo.used = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9794 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9795 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9796 void printTestCaseAndSectionHeader() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9797 assert( !m_sectionStack.empty() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9798 printOpenHeader( currentTestCaseInfo->name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9799
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9800 if( m_sectionStack.size() > 1 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9801 Colour colourGuard( Colour::Headers );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9802
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9803 std::vector<SectionInfo>::const_iterator
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9804 it = m_sectionStack.begin()+1, // Skip first section (test case)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9805 itEnd = m_sectionStack.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9806 for( ; it != itEnd; ++it )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9807 printHeaderString( it->name, 2 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9808 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9809
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9810 SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9811
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9812 if( !lineInfo.empty() ){
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9813 stream << getLineOfChars<'-'>() << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9814 Colour colourGuard( Colour::FileName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9815 stream << lineInfo << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9816 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9817 stream << getLineOfChars<'.'>() << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9818 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9819
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9820 void printClosedHeader( std::string const& _name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9821 printOpenHeader( _name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9822 stream << getLineOfChars<'.'>() << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9823 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9824 void printOpenHeader( std::string const& _name ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9825 stream << getLineOfChars<'-'>() << "\n";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9826 {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9827 Colour colourGuard( Colour::Headers );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9828 printHeaderString( _name );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9829 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9830 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9831
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9832 // if string has a : in first line will set indent to follow it on
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9833 // subsequent lines
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9834 void printHeaderString( std::string const& _string, std::size_t indent = 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9835 std::size_t i = _string.find( ": " );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9836 if( i != std::string::npos )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9837 i+=2;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9838 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9839 i = 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9840 stream << Text( _string, TextAttributes()
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9841 .setIndent( indent+i)
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9842 .setInitialIndent( indent ) ) << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9843 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9844
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9845 struct SummaryColumn {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9846
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9847 SummaryColumn( std::string const& _label, Colour::Code _colour )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9848 : label( _label ),
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9849 colour( _colour )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9850 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9851 SummaryColumn addRow( std::size_t count ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9852 std::ostringstream oss;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9853 oss << count;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9854 std::string row = oss.str();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9855 for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9856 while( it->size() < row.size() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9857 *it = " " + *it;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9858 while( it->size() > row.size() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9859 row = " " + row;
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9860 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9861 rows.push_back( row );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9862 return *this;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9863 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9864
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9865 std::string label;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9866 Colour::Code colour;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9867 std::vector<std::string> rows;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9868
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9869 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9870
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9871 void printTotals( Totals const& totals ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9872 if( totals.testCases.total() == 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9873 stream << Colour( Colour::Warning ) << "No tests ran\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9874 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9875 else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9876 stream << Colour( Colour::ResultSuccess ) << "All tests passed";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9877 stream << " ("
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9878 << pluralise( totals.assertions.passed, "assertion" ) << " in "
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9879 << pluralise( totals.testCases.passed, "test case" ) << ")"
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9880 << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9881 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9882 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9883
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9884 std::vector<SummaryColumn> columns;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9885 columns.push_back( SummaryColumn( "", Colour::None )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9886 .addRow( totals.testCases.total() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9887 .addRow( totals.assertions.total() ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9888 columns.push_back( SummaryColumn( "passed", Colour::Success )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9889 .addRow( totals.testCases.passed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9890 .addRow( totals.assertions.passed ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9891 columns.push_back( SummaryColumn( "failed", Colour::ResultError )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9892 .addRow( totals.testCases.failed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9893 .addRow( totals.assertions.failed ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9894 columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9895 .addRow( totals.testCases.failedButOk )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9896 .addRow( totals.assertions.failedButOk ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9897
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9898 printSummaryRow( "test cases", columns, 0 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9899 printSummaryRow( "assertions", columns, 1 );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9900 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9901 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9902 void printSummaryRow( std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9903 for( std::vector<SummaryColumn>::const_iterator it = cols.begin(); it != cols.end(); ++it ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9904 std::string value = it->rows[row];
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9905 if( it->label.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9906 stream << label << ": ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9907 if( value != "0" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9908 stream << value;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9909 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9910 stream << Colour( Colour::Warning ) << "- none -";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9911 }
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9912 else if( value != "0" ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9913 stream << Colour( Colour::LightGrey ) << " | ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9914 stream << Colour( it->colour )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9915 << value << " " << it->label;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9916 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9917 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9918 stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9919 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9920
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9921 static std::size_t makeRatio( std::size_t number, std::size_t total ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9922 std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9923 return ( ratio == 0 && number > 0 ) ? 1 : ratio;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9924 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9925 static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9926 if( i > j && i > k )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9927 return i;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9928 else if( j > k )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9929 return j;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9930 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9931 return k;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9932 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9933
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9934 void printTotalsDivider( Totals const& totals ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9935 if( totals.testCases.total() > 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9936 std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9937 std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9938 std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9939 while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9940 findMax( failedRatio, failedButOkRatio, passedRatio )++;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9941 while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9942 findMax( failedRatio, failedButOkRatio, passedRatio )--;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9943
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9944 stream << Colour( Colour::Error ) << std::string( failedRatio, '=' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9945 stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9946 if( totals.testCases.allPassed() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9947 stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9948 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9949 stream << Colour( Colour::Success ) << std::string( passedRatio, '=' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9950 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9951 else {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9952 stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9953 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9954 stream << "\n";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9955 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9956 void printSummaryDivider() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9957 stream << getLineOfChars<'-'>() << "\n";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9958 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9959
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9960 private:
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9961 bool m_headerPrinted;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9962 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9963
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9964 INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9965
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9966 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9967
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9968 // #included from: ../reporters/catch_reporter_compact.hpp
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9969 #define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9970
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9971 namespace Catch {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9972
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9973 struct CompactReporter : StreamingReporterBase {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9974
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9975 CompactReporter( ReporterConfig const& _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9976 : StreamingReporterBase( _config )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9977 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9978
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9979 virtual ~CompactReporter();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9980
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9981 static std::string getDescription() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9982 return "Reports test results on a single line, suitable for IDEs";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9983 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9984
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9985 virtual ReporterPreferences getPreferences() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9986 ReporterPreferences prefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9987 prefs.shouldRedirectStdOut = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9988 return prefs;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9989 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9990
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9991 virtual void noMatchingTestCases( std::string const& spec ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9992 stream << "No test cases matched '" << spec << "'" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9993 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9994
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9995 virtual void assertionStarting( AssertionInfo const& ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9996 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9997
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9998 virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
9999 AssertionResult const& result = _assertionStats.assertionResult;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10000
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10001 bool printInfoMessages = true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10002
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10003 // Drop out if result was successful and we're not printing those
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10004 if( !m_config->includeSuccessfulResults() && result.isOk() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10005 if( result.getResultType() != ResultWas::Warning )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10006 return false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10007 printInfoMessages = false;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10008 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10009
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10010 AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10011 printer.print();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10012
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10013 stream << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10014 return true;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10015 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10016
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10017 virtual void testRunEnded( TestRunStats const& _testRunStats ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10018 printTotals( _testRunStats.totals );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10019 stream << "\n" << std::endl;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10020 StreamingReporterBase::testRunEnded( _testRunStats );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10021 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10022
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10023 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10024 class AssertionPrinter {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10025 void operator= ( AssertionPrinter const& );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10026 public:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10027 AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10028 : stream( _stream )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10029 , stats( _stats )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10030 , result( _stats.assertionResult )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10031 , messages( _stats.infoMessages )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10032 , itMessage( _stats.infoMessages.begin() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10033 , printInfoMessages( _printInfoMessages )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10034 {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10035
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10036 void print() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10037 printSourceInfo();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10038
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10039 itMessage = messages.begin();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10040
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10041 switch( result.getResultType() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10042 case ResultWas::Ok:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10043 printResultType( Colour::ResultSuccess, passedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10044 printOriginalExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10045 printReconstructedExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10046 if ( ! result.hasExpression() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10047 printRemainingMessages( Colour::None );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10048 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10049 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10050 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10051 case ResultWas::ExpressionFailed:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10052 if( result.isOk() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10053 printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10054 else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10055 printResultType( Colour::Error, failedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10056 printOriginalExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10057 printReconstructedExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10058 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10059 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10060 case ResultWas::ThrewException:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10061 printResultType( Colour::Error, failedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10062 printIssue( "unexpected exception with message:" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10063 printMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10064 printExpressionWas();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10065 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10066 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10067 case ResultWas::FatalErrorCondition:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10068 printResultType( Colour::Error, failedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10069 printIssue( "fatal error condition with message:" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10070 printMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10071 printExpressionWas();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10072 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10073 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10074 case ResultWas::DidntThrowException:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10075 printResultType( Colour::Error, failedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10076 printIssue( "expected exception, got none" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10077 printExpressionWas();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10078 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10079 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10080 case ResultWas::Info:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10081 printResultType( Colour::None, "info" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10082 printMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10083 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10084 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10085 case ResultWas::Warning:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10086 printResultType( Colour::None, "warning" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10087 printMessage();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10088 printRemainingMessages();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10089 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10090 case ResultWas::ExplicitFailure:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10091 printResultType( Colour::Error, failedString() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10092 printIssue( "explicitly" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10093 printRemainingMessages( Colour::None );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10094 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10095 // These cases are here to prevent compiler warnings
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10096 case ResultWas::Unknown:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10097 case ResultWas::FailureBit:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10098 case ResultWas::Exception:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10099 printResultType( Colour::Error, "** internal error **" );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10100 break;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10101 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10102 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10103
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10104 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10105 // Colour::LightGrey
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10106
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10107 static Colour::Code dimColour() { return Colour::FileName; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10108
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10109 #ifdef CATCH_PLATFORM_MAC
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10110 static const char* failedString() { return "FAILED"; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10111 static const char* passedString() { return "PASSED"; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10112 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10113 static const char* failedString() { return "failed"; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10114 static const char* passedString() { return "passed"; }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10115 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10116
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10117 void printSourceInfo() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10118 Colour colourGuard( Colour::FileName );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10119 stream << result.getSourceInfo() << ":";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10120 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10121
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10122 void printResultType( Colour::Code colour, std::string passOrFail ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10123 if( !passOrFail.empty() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10124 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10125 Colour colourGuard( colour );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10126 stream << " " << passOrFail;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10127 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10128 stream << ":";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10129 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10130 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10131
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10132 void printIssue( std::string issue ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10133 stream << " " << issue;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10134 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10135
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10136 void printExpressionWas() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10137 if( result.hasExpression() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10138 stream << ";";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10139 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10140 Colour colour( dimColour() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10141 stream << " expression was:";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10142 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10143 printOriginalExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10144 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10145 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10146
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10147 void printOriginalExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10148 if( result.hasExpression() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10149 stream << " " << result.getExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10150 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10151 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10152
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10153 void printReconstructedExpression() const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10154 if( result.hasExpandedExpression() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10155 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10156 Colour colour( dimColour() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10157 stream << " for: ";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10158 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10159 stream << result.getExpandedExpression();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10160 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10161 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10162
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10163 void printMessage() {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10164 if ( itMessage != messages.end() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10165 stream << " '" << itMessage->message << "'";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10166 ++itMessage;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10167 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10168 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10169
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10170 void printRemainingMessages( Colour::Code colour = dimColour() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10171 if ( itMessage == messages.end() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10172 return;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10173
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10174 // using messages.end() directly yields compilation error:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10175 std::vector<MessageInfo>::const_iterator itEnd = messages.end();
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10176 const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10177
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10178 {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10179 Colour colourGuard( colour );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10180 stream << " with " << pluralise( N, "message" ) << ":";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10181 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10182
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10183 for(; itMessage != itEnd; ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10184 // If this assertion is a warning ignore any INFO messages
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10185 if( printInfoMessages || itMessage->type != ResultWas::Info ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10186 stream << " '" << itMessage->message << "'";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10187 if ( ++itMessage != itEnd ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10188 Colour colourGuard( dimColour() );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10189 stream << " and";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10190 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10191 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10192 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10193 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10194
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10195 private:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10196 std::ostream& stream;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10197 AssertionStats const& stats;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10198 AssertionResult const& result;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10199 std::vector<MessageInfo> messages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10200 std::vector<MessageInfo>::const_iterator itMessage;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10201 bool printInfoMessages;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10202 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10203
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10204 // Colour, message variants:
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10205 // - white: No tests ran.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10206 // - red: Failed [both/all] N test cases, failed [both/all] M assertions.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10207 // - white: Passed [both/all] N test cases (no assertions).
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10208 // - red: Failed N tests cases, failed M assertions.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10209 // - green: Passed [both/all] N tests cases with M assertions.
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10210
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10211 std::string bothOrAll( std::size_t count ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10212 return count == 1 ? "" : count == 2 ? "both " : "all " ;
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10213 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10214
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10215 void printTotals( const Totals& totals ) const {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10216 if( totals.testCases.total() == 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10217 stream << "No tests ran.";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10218 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10219 else if( totals.testCases.failed == totals.testCases.total() ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10220 Colour colour( Colour::ResultError );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10221 const std::string qualify_assertions_failed =
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10222 totals.assertions.failed == totals.assertions.total() ?
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10223 bothOrAll( totals.assertions.failed ) : "";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10224 stream <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10225 "Failed " << bothOrAll( totals.testCases.failed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10226 << pluralise( totals.testCases.failed, "test case" ) << ", "
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10227 "failed " << qualify_assertions_failed <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10228 pluralise( totals.assertions.failed, "assertion" ) << ".";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10229 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10230 else if( totals.assertions.total() == 0 ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10231 stream <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10232 "Passed " << bothOrAll( totals.testCases.total() )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10233 << pluralise( totals.testCases.total(), "test case" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10234 << " (no assertions).";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10235 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10236 else if( totals.assertions.failed ) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10237 Colour colour( Colour::ResultError );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10238 stream <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10239 "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", "
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10240 "failed " << pluralise( totals.assertions.failed, "assertion" ) << ".";
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10241 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10242 else {
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10243 Colour colour( Colour::ResultSuccess );
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10244 stream <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10245 "Passed " << bothOrAll( totals.testCases.passed )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10246 << pluralise( totals.testCases.passed, "test case" ) <<
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10247 " with " << pluralise( totals.assertions.passed, "assertion" ) << ".";
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10248 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10249 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10250 };
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10251
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10252 INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10253
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10254 } // end namespace Catch
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10255
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10256 namespace Catch {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10257 // These are all here to avoid warnings about not having any out of line
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10258 // virtual methods
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10259 NonCopyable::~NonCopyable() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10260 IShared::~IShared() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10261 IStream::~IStream() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10262 FileStream::~FileStream() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10263 CoutStream::~CoutStream() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10264 DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10265 StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10266 IContext::~IContext() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10267 IResultCapture::~IResultCapture() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10268 ITestCase::~ITestCase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10269 ITestCaseRegistry::~ITestCaseRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10270 IRegistryHub::~IRegistryHub() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10271 IMutableRegistryHub::~IMutableRegistryHub() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10272 IExceptionTranslator::~IExceptionTranslator() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10273 IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10274 IReporter::~IReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10275 IReporterFactory::~IReporterFactory() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10276 IReporterRegistry::~IReporterRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10277 IStreamingReporter::~IStreamingReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10278 AssertionStats::~AssertionStats() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10279 SectionStats::~SectionStats() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10280 TestCaseStats::~TestCaseStats() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10281 TestGroupStats::~TestGroupStats() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10282 TestRunStats::~TestRunStats() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10283 CumulativeReporterBase::SectionNode::~SectionNode() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10284 CumulativeReporterBase::~CumulativeReporterBase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10285
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10286 StreamingReporterBase::~StreamingReporterBase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10287 ConsoleReporter::~ConsoleReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10288 CompactReporter::~CompactReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10289 IRunner::~IRunner() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10290 IMutableContext::~IMutableContext() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10291 IConfig::~IConfig() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10292 XmlReporter::~XmlReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10293 JunitReporter::~JunitReporter() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10294 TestRegistry::~TestRegistry() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10295 FreeFunctionTestCase::~FreeFunctionTestCase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10296 IGeneratorInfo::~IGeneratorInfo() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10297 IGeneratorsForTest::~IGeneratorsForTest() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10298 WildcardPattern::~WildcardPattern() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10299 TestSpec::Pattern::~Pattern() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10300 TestSpec::NamePattern::~NamePattern() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10301 TestSpec::TagPattern::~TagPattern() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10302 TestSpec::ExcludedPattern::~ExcludedPattern() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10303
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10304 Matchers::Impl::StdString::Equals::~Equals() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10305 Matchers::Impl::StdString::Contains::~Contains() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10306 Matchers::Impl::StdString::StartsWith::~StartsWith() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10307 Matchers::Impl::StdString::EndsWith::~EndsWith() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10308
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10309 void Config::dummy() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10310
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10311 namespace TestCaseTracking {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10312 ITracker::~ITracker() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10313 TrackerBase::~TrackerBase() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10314 SectionTracker::~SectionTracker() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10315 IndexTracker::~IndexTracker() {}
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10316 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10317 }
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10318
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10319 #ifdef __clang__
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10320 #pragma clang diagnostic pop
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10321 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10322
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10323 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10324
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10325 #ifdef CATCH_CONFIG_MAIN
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10326 // #included from: internal/catch_default_main.hpp
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10327 #define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10328
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10329 #ifndef __OBJC__
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10330
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10331 // Standard C/C++ main entry point
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10332 int main (int argc, char * argv[]) {
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10333 return Catch::Session().run( argc, argv );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10334 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10335
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10336 #else // __OBJC__
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10337
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10338 // Objective-C entry point
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10339 int main (int argc, char * const argv[]) {
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10340 #if !CATCH_ARC_ENABLED
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10341 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10342 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10343
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10344 Catch::registerTestMethods();
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10345 int result = Catch::Session().run( argc, (char* const*)argv );
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10346
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10347 #if !CATCH_ARC_ENABLED
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10348 [pool drain];
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10349 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10350
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10351 return result;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10352 }
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10353
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10354 #endif // __OBJC__
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10355
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10356 #endif
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10357
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10358 #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10359 # undef CLARA_CONFIG_MAIN
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10360 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10361
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10362 //////
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10363
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10364 // If this config identifier is defined then all CATCH macros are prefixed with CATCH_
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10365 #ifdef CATCH_CONFIG_PREFIX_ALL
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10366
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10367 #define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10368 #define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10369
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10370 #define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10371 #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10372 #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10373 #define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10374
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10375 #define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10376 #define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10377 #define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10378 #define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10379 #define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10380
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10381 #define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10382 #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10383 #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10384 #define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10385
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10386 #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10387 #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10388
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10389 #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10390 #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10391 #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10392 #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10393 #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10394
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10395 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10396 #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10397 #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10398 #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10399 #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10400 #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10401 #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10402 #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10403 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10404 #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10405 #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10406 #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10407 #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10408 #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10409 #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10410 #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10411 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10412 #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10413
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10414 #define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10415 #define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10416
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10417 #define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10418
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10419 // "BDD-style" convenience wrappers
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10420 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10421 #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10422 #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10423 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10424 #define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10425 #define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10426 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10427 #define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10428 #define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10429 #define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10430 #define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10431 #define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10432
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10433 // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10434 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10435
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10436 #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10437 #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10438
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10439 #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10440 #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10441 #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10442 #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10443
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10444 #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10445 #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10446 #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10447 #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10448 #define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10449
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10450 #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10451 #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10452 #define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10453 #define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10454
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10455 #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10456 #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10457
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10458 #define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10459 #define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10460 #define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10461 #define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10462 #define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10463
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10464 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10465 #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10466 #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10467 #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10468 #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10469 #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10470 #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10471 #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10472 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10473 #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10474 #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10475 #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10476 #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10477 #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10478 #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10479 #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10480 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10481 #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10482
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10483 #define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10484 #define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10485
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10486 #define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10487
806
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10488 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10489
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10490 #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10491
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10492 // "BDD-style" convenience wrappers
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10493 #ifdef CATCH_CONFIG_VARIADIC_MACROS
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10494 #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10495 #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10496 #else
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10497 #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10498 #define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10499 #endif
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10500 #define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10501 #define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10502 #define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10503 #define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
c6f497291fd8 updated catch and C++ code to opencv2.4.13
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 220
diff changeset
10504 #define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
220
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10505
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10506 using Catch::Detail::Approx;
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10507
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10508 #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
f0f800b95765 switched to Catch for the tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10509