Skip to content

Commit a1662b8

Browse files
committed
test(*): reduced duplications
1 parent b17875c commit a1662b8

37 files changed

+334
-311
lines changed

include/stdsharp/memory/allocation_value.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ namespace stdsharp
8888
using m_base::size_validate;
8989

9090
template<typename Allocation>
91-
[[nodiscard]] constexpr decltype(auto) forward_value(const Allocation& src_allocation) const noexcept
91+
[[nodiscard]] constexpr decltype(auto) forward_value(const Allocation& src_allocation
92+
) const noexcept
9293
{
9394
size_validate(src_allocation);
9495
return static_cast<forward_value_t<Allocation>>(get(src_allocation));

include/stdsharp/type_traits/regular_type_sequence.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace std
2525
};
2626

2727
template<::stdsharp::adl_proofed_for<::stdsharp::basic_type_sequence> T>
28-
struct tuple_size<T> : tuple_size<typename T::basic_type_sequence>
28+
struct tuple_size<T> : tuple_size<::stdsharp::adl_proof_inner_t<T>>
2929
{
3030
};
3131
}

include/stdsharp/utility/adl_proof.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace stdsharp
3131
using adl_proof_t = adl_proof_traits<Inner>::template types<T...>::proofed_t;
3232

3333
template<typename T>
34-
using adl_proof_inner_t = decltype(get_inner(std::declval<T>()));
34+
using adl_proof_inner_t = typename decltype(get_types(std::declval<T>()))::inner_t;
3535
}
3636

3737
namespace stdsharp::details

tests/.clang-tidy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
---
22
InheritParentConfig: true
3-
Checks: '-*-magic-numbers,-*-chained-comparison,-*-move-const-arg,-*-const-correctness'
3+
Checks:
4+
- '-*-magic-numbers,
5+
-*-chained-comparison,
6+
-*-move-const-arg,
7+
-*-const-correctness,
8+
-*-function-cognitive-complexity'

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set(src
3131
src/type_traits/member.cpp
3232
src/type_traits/type_sequence.cpp
3333
src/type_traits/value_sequence.cpp
34+
src/utility/adl_proof.cpp
3435
src/utility/dispatcher.cpp
3536
src/utility/forward_cast.cpp
3637
src/utility/utility.cpp

tests/include/box.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#pragma once
2+
3+
#include "test.h"
4+
5+
#include <stdsharp/concepts/concepts.h>
6+
7+
struct test_worst_type
8+
{
9+
test_worst_type() = default;
10+
~test_worst_type() = default;
11+
12+
private:
13+
test_worst_type(const test_worst_type&) = default;
14+
test_worst_type(test_worst_type&&) = default;
15+
test_worst_type& operator=(const test_worst_type&) = default;
16+
test_worst_type& operator=(test_worst_type&&) = default;
17+
};
18+
19+
#define ALLOCATION_TYPE_REQUIRE(Normal, Unique, Worst) \
20+
STATIC_REQUIRE(copyable<Normal>); \
21+
STATIC_REQUIRE(nothrow_movable<Unique>); \
22+
STATIC_REQUIRE(nothrow_swappable<Unique>); \
23+
STATIC_REQUIRE(nothrow_movable<Worst>); \
24+
STATIC_REQUIRE(nothrow_swappable<Worst>)
25+
26+
#define BOX_EMPLACE_TEST(...) \
27+
GIVEN("a box") \
28+
{ \
29+
TestType data; \
30+
auto box_v = __VA_ARGS__; \
31+
WHEN("emplace the value") \
32+
{ \
33+
const auto& const_value = data.value; \
34+
const auto& res = box_v.emplace(const_value); \
35+
THEN("check the value") { REQUIRE(res == const_value); } \
36+
AND_THEN("type should be expected") \
37+
{ \
38+
REQUIRE(box_v.is_type<decltype(data.value)>()); \
39+
} \
40+
} \
41+
}

tests/include/test.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ namespace stdsharp
88
{
99
}
1010

11-
using namespace std;
12-
using namespace stdsharp;
11+
#define STDSHARP_TEST_NAMESPACES \
12+
using namespace std; \
13+
using namespace stdsharp

tests/include/test_allocator.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/include/test_worst_type.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/src/algorithm/algorithm.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "stdsharp/algorithm/algorithm.h"
22
#include "test.h"
33

4-
TEMPLATE_TEST_CASE_SIG( // NOLINT
4+
STDSHARP_TEST_NAMESPACES;
5+
6+
TEMPLATE_TEST_CASE_SIG(
57
"Scenario: set if",
68
"[algorithm]",
79
((auto First, auto Second), First, Second),
@@ -28,7 +30,7 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT
2830
}
2931
}
3032

31-
TEMPLATE_TEST_CASE_SIG( // NOLINT
33+
TEMPLATE_TEST_CASE_SIG(
3234
"Scenario: is between",
3335
"[algorithm]",
3436
((auto Value, auto Min, auto Max), Value, Min, Max),
@@ -62,7 +64,7 @@ namespace
6264
constexpr auto unordered = [] { return partial_ordering::unordered; };
6365
}
6466

65-
TEMPLATE_TEST_CASE_SIG( // NOLINT
67+
TEMPLATE_TEST_CASE_SIG(
6668
"Scenario: strict compare",
6769
"[algorithm]",
6870
((auto Left, auto Right, auto GetCmp), Left, Right, GetCmp),

0 commit comments

Comments
 (0)