1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-13 14:42:28 +03:00

🏗️ adding anonymous namespace

This commit is contained in:
Niels Lohmann
2019-04-04 08:56:36 +02:00
parent 0da99027b7
commit f05614b240
16 changed files with 51 additions and 8 deletions

View File

@@ -34,8 +34,9 @@ SOFTWARE.
using nlohmann::json;
#undef private
namespace
{
// special test case to check if memory is leaked if constructor throws
template<class T>
struct bad_allocator : std::allocator<T>
{
@@ -45,6 +46,7 @@ struct bad_allocator : std::allocator<T>
throw std::bad_alloc();
}
};
}
TEST_CASE("bad_alloc")
{
@@ -65,6 +67,8 @@ TEST_CASE("bad_alloc")
}
}
namespace
{
static bool next_construct_fails = false;
static bool next_destroy_fails = false;
static bool next_deallocate_fails = false;
@@ -130,6 +134,7 @@ void my_allocator_clean_up(T* p)
alloc.destroy(p);
alloc.deallocate(p, 1);
}
}
TEST_CASE("controlled bad_alloc")
{