fixing CI builds - no C++11...
diff --git a/doc/markdown/stringification.md b/doc/markdown/stringification.md
index fe9af89..3e4cc7c 100644
--- a/doc/markdown/stringification.md
+++ b/doc/markdown/stringification.md
@@ -59,11 +59,11 @@
## Translating exceptions
-By default all exceptions deriving from ```std::exception``` will be translated to strings by calling the what() method. For exception types that do not derive from ```std::exception``` - or if ```what()``` does not return a suitable string - use ```REGISTER_EXCEPTION_TRANSLATOR```. This defines a function that takes your exception type and returns a ```doctest::String```. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:
+By default all exceptions deriving from ```std::exception``` will be translated to strings by calling the ```what()``` method. For exception types that do not derive from ```std::exception``` - or if ```what()``` does not return a suitable string - use ```REGISTER_EXCEPTION_TRANSLATOR```. This defines a function that takes your exception type and returns a ```doctest::String```. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:
```c++
REGISTER_EXCEPTION_TRANSLATOR(MyType& ex) {
- return doctest::String(ex.message());
+ return doctest::String(ex.message());
}
```
@@ -73,7 +73,7 @@
```c++
// adding a lambda - the signature required as a function pointer is `doctest::String(*)(exception_type)`
- doctest::registerExceptionTranslator<int>([](int in){ return doctest::String("int: ") + doctest::toString(in); });
+ doctest::registerExceptionTranslator<int>([](int in){ return doctest::toString(in); });
```
The order of registering exception translators can be controlled - simply call the explicit function in the required order or list the exception translators with the macro in a top-to-bottom fashion in a single translation unit - everything that auto-registers in doctest works in a top-to-bottom way for a single translation unit (source file).
diff --git a/examples/disabled/main.cpp b/examples/disabled/main.cpp
index a5a62c2..5fcfe79 100644
--- a/examples/disabled/main.cpp
+++ b/examples/disabled/main.cpp
@@ -8,9 +8,11 @@
return doctest::String("double: ") + doctest::toString(e);
}
+static doctest::String intTranslator(int ex) { return doctest::String("int: ") + doctest::toString(ex); }
+
int main(int argc, char** argv) {
// set an exception translator for int
- doctest::registerExceptionTranslator<int>([](int in){ return doctest::String("int: ") + doctest::toString(in); });
+ doctest::registerExceptionTranslator(intTranslator);
doctest::Context context; // initialize
diff --git a/examples/stringification/main.cpp b/examples/stringification/main.cpp
index 46798d3..d5820e2 100644
--- a/examples/stringification/main.cpp
+++ b/examples/stringification/main.cpp
@@ -132,10 +132,12 @@
throw bla1;
}
+static doctest::String intTranslator(int ex) { return doctest::String("int: ") + doctest::toString(ex); }
+
TEST_CASE("a test case that registers an exception translator for int and then throws one") {
// set an exception translator for int - note that this shouldn't be done in a test case but
// in main() or somewhere before executing the tests - but here I'm lazy to write my own main...
- doctest::registerExceptionTranslator<int>([](int in){ return doctest::String("int: ") + doctest::toString(in); });
+ doctest::registerExceptionTranslator(intTranslator);
throw 42;
}