Skip to content

Commit

Permalink
Connect new libcxx tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jan 4, 2024
1 parent 058ac33 commit 90380ed
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 3 deletions.
13 changes: 13 additions & 0 deletions test/sources/LibcxxHashMultiMapTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include "../../include/momo/stdish/unordered_multimap.h"

#ifdef TEST_LIBCXX_NEW
#include "../../include/momo/stdish/set.h"
#endif

namespace
{

Expand All @@ -29,6 +33,7 @@ namespace libcxx_test_hash_multimap
{

LIBCXX_NAMESPACE_STD_BEGIN

template<typename TKey, typename TMapped,
typename THashFunc = std::hash<TKey>,
typename TEqualFunc = std::equal_to<TKey>,
Expand All @@ -38,6 +43,14 @@ using unordered_multimap = momo::stdish::unordered_multimap<TKey, TMapped, THash
momo::MemManagerStd<TAllocator>,
momo::HashMultiMapKeyValueTraits<TKey, TMapped, momo::MemManagerStd<TAllocator>>,
LibcxxHashMultiMapSettings>>;

#ifdef TEST_LIBCXX_NEW
template<typename TKey>
using set = momo::stdish::set<TKey>;
template<typename TKey>
using multiset = momo::stdish::multiset<TKey>;
#endif

LIBCXX_NAMESPACE_STD_END

#define LIBCXX_TEST_FAILURE
Expand Down
13 changes: 13 additions & 0 deletions test/sources/LibcxxHashMultiMapTesterOpen8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,32 @@

#include "../../include/momo/stdish/unordered_multimap.h"

#ifdef TEST_LIBCXX_NEW
#include "../../include/momo/stdish/set.h"
#endif

namespace
{

namespace libcxx_test_hash_multimap
{

LIBCXX_NAMESPACE_STD_BEGIN

template<typename TKey, typename TMapped,
typename THashFunc = std::hash<TKey>,
typename TEqualFunc = std::equal_to<TKey>,
typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>>
using unordered_multimap = momo::stdish::unordered_multimap_open<TKey, TMapped,
THashFunc, TEqualFunc, TAllocator>;

#ifdef TEST_LIBCXX_NEW
template<typename TKey>
using set = momo::stdish::set<TKey>;
template<typename TKey>
using multiset = momo::stdish::multiset<TKey>;
#endif

LIBCXX_NAMESPACE_STD_END

#define LIBCXX_TEST_PREFIX "libcxx_test_hash_multimap_open"
Expand Down
4 changes: 4 additions & 0 deletions test/sources/LibcxxTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "LibcxxTester.h"

#ifndef TEST_LIBCXX_NEW

int DefaultOnly::count = 0;

int Counter_base::gConstructed = 0;
Expand All @@ -25,3 +27,5 @@ int test_alloc_base::throw_after = INT_MAX;
int test_alloc_base::copied = 0;
int test_alloc_base::moved = 0;
int test_alloc_base::converted = 0;

#endif // TEST_LIBCXX_NEW
68 changes: 65 additions & 3 deletions test/sources/LibcxxTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,38 @@

#pragma once

#include <iostream>

#define LIBCXX_TO_STR(expr) #expr
#define LIBCXX_HEADER(header) LIBCXX_TO_STR(libcxx11/header)

#include LIBCXX_HEADER(Support.h)
#ifdef TEST_LIBCXX_NEW

#include <iostream>
#define LIBCXX_NAMESPACE_STD_BEGIN namespace std { using namespace ::std;

#define LIBCXX_NAMESPACE_STD_END }

#define LIBCXX_TEST_BEGIN(name) \
namespace name \
{ \
template<typename Main> \
int TestLibcxx(Main main) \
{ \
std::cout << LIBCXX_TEST_PREFIX << "_" << #name << ": " << std::flush; \
if constexpr (std::is_same_v<Main, void (*)()>) \
main(); \
else \
main(0, nullptr); \
std::cout << "ok" << std::endl; \
return 0; \
}

#define LIBCXX_TEST_END \
static int testLibcxx = TestLibcxx(&main); \
}

#define LIBCXX_HEADER(header) LIBCXX_TO_STR(libcxx/header)

#else // TEST_LIBCXX_NEW

#define LIBCXX_NAMESPACE_STD_BEGIN

Expand All @@ -35,3 +61,39 @@
}();

#define LIBCXX_TEST_END }

#define LIBCXX_HEADER(header) LIBCXX_TO_STR(libcxx11/header)

#endif // TEST_LIBCXX_NEW

#include LIBCXX_HEADER(Support.h)

#ifdef TEST_LIBCXX_NEW

#include "../../include/momo/Version.h"
#include "../../include/momo/ObjectManager.h"

namespace momo
{
template<int Dummy, typename TMemManager>
class ObjectRelocator<CopyInsertable<Dummy>, TMemManager>
{
public:
typedef CopyInsertable<Dummy> Object;
typedef TMemManager MemManager;

static const bool isTriviallyRelocatable = false;
static const bool isNothrowRelocatable = true;

public:
static void Relocate(MemManager* /*memManager*/, Object& srcObject, Object* dstObject) noexcept
{
std::construct_at(dstObject, srcObject.data);
dstObject->copied_once = srcObject.copied_once;
dstObject->constructed_under_allocator = srcObject.constructed_under_allocator;
std::destroy_at(&srcObject);
}
};
}

#endif // TEST_LIBCXX_NEW
4 changes: 4 additions & 0 deletions test/sources/LibcxxTreeMapTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#include "../../include/momo/stdish/map.h"

#ifdef TEST_LIBCXX_NEW
#include "../../include/momo/stdish/vector.h"
#endif

namespace libcxx_test_tree_map
{

Expand Down
2 changes: 2 additions & 0 deletions test/sources/TestSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#undef TEST_LIBCXX_TREE_MAP
#endif

//#define TEST_LIBCXX_NEW

//#define TEST_NATVIS

#define TEST_OLD_HASH_BUCKETS
Expand Down

0 comments on commit 90380ed

Please sign in to comment.