What is the issue you have?
I was trying out https://github.com/nlohmann/json and wanted to test the exception mechanism it had.
My initial attempt was to use CHECK_THROWS but that was really difficult since nlohmann::json::out_of_range is not easy to construct.
CHECK_THROWS_AS was what I was supposed to use and that worked fine.
Before figure that out I tried CHECK_THROWS with std::out_of_range and to my surprise that worked! The test also passed with std::bad_alloc.
I am not sure if this is to be expected since nlohmann::json::out_of_range is derived from std::exception.
Please describe the steps to reproduce the issue.
This Code snippet
Can you provide a small but working code example?
Minimal example here: https://github.com/nandanvasudevan/cpp_scratch_pad/tree/json_parsing
What is the expected behavior?
I expect the above tests to fail.
catchorg/Catch2#2371
And what is the actual behavior instead?
The tests pass.
Which compiler and operating system are you using?
- Compiler: GCC v11
- Operating system: Jammy Jellyfish (development branch)
- Test framework: Catch2 v3 Preview 4
Which version of the library did you use?
Compiles fine.
What is the issue you have?
I was trying out https://github.com/nlohmann/json and wanted to test the exception mechanism it had.
My initial attempt was to use
CHECK_THROWSbut that was really difficult sincenlohmann::json::out_of_rangeis not easy to construct.CHECK_THROWS_ASwas what I was supposed to use and that worked fine.Before figure that out I tried
CHECK_THROWSwithstd::out_of_rangeand to my surprise that worked! The test also passed withstd::bad_alloc.I am not sure if this is to be expected since
nlohmann::json::out_of_rangeis derived from std::exception.Please describe the steps to reproduce the issue.
This
Code snippetCan you provide a small but working code example?
Minimal example here: https://github.com/nandanvasudevan/cpp_scratch_pad/tree/json_parsing
What is the expected behavior?
I expect the above tests to fail.
catchorg/Catch2#2371
And what is the actual behavior instead?
The tests pass.
Which compiler and operating system are you using?
Which version of the library did you use?
developbranchIf you experience a compilation error: can you compile and run the unit tests?
Compiles fine.