moved from Catch to doctest for unit tests

This commit is contained in:
onqtam 2019-01-13 18:41:21 +02:00
parent e5753b14a8
commit 2f44ac1def
52 changed files with 5517 additions and 11854 deletions

View file

@ -27,11 +27,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "catch.hpp"
#include "doctest_compatibility.h"
// for some reason including this after the json header leads to linker errors with VS 2017...
#include <locale>
#define private public
#include <nlohmann/json.hpp>
using nlohmann::json;
#undef private
#include <fstream>
#include <sstream>
#include <list>
#include <cstdio>
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
@ -43,10 +52,6 @@ using nlohmann::json;
#include "fifo_map.hpp"
#include <fstream>
#include <list>
#include <cstdio>
/////////////////////////////////////////////////////////////////////
// for #972
/////////////////////////////////////////////////////////////////////
@ -295,8 +300,7 @@ TEST_CASE("regression tests")
nlohmann::basic_json<std::map, std::vector, std::string, bool, int32_t, uint32_t, float>;
custom_json j;
j["int_1"] = 1;
// we need to cast to int to compile with Catch - the value is int32_t
CHECK(static_cast<int>(j["int_1"]) == 1);
CHECK(j["int_1"] == 1);
// tests for correct handling of non-standard integers that overflow the type selected by the user
@ -1710,7 +1714,8 @@ TEST_CASE("regression tests")
}
}
TEST_CASE("regression tests, exceptions dependent", "[!throws]")
#if not defined(JSON_NOEXCEPTION)
TEST_CASE("regression tests, exceptions dependent")
{
SECTION("issue #1340 - eof not set on exhausted input stream")
{
@ -1722,3 +1727,4 @@ TEST_CASE("regression tests, exceptions dependent", "[!throws]")
CHECK(s.eof());
}
}
#endif