Skip to content

Commit 94cb4e4

Browse files
committed
test(*): more coverage
1 parent 713f189 commit 94cb4e4

File tree

4 files changed

+54
-50
lines changed

4 files changed

+54
-50
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.24)
55
#
66
project(
77
stdsharp
8-
VERSION 0.9.0
8+
VERSION 0.9.1
99
LANGUAGES CXX)
1010

1111
include(cmake/Utils.cmake)

include/stdsharp/synchronizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace stdsharp
3838

3939
private:
4040
template<typename Lock, typename... Args, typename T, typename Self>
41-
// requires std::constructible_from<Lock, lock_type&, Args...>
41+
requires std::constructible_from<Lock, lock_type&, Args...>
4242
constexpr auto write_impl(this Self&& self, T&& value, Args&&... args)
4343
{
4444
using cast_t = forward_cast_t<Self, T>;

tests/src/default_operator.cpp

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ STDSHARP_TEST_NAMESPACES;
66
using namespace default_operator;
77

88
template<typename T>
9-
void arithmetic_test()
9+
void arithmetic_test([[maybe_unused]] T v = {})
1010
{
11-
[[maybe_unused]] T v{};
11+
STATIC_REQUIRE(requires { v += 1; });
12+
STATIC_REQUIRE(requires { v -= 1; });
13+
STATIC_REQUIRE(requires { v *= 1; });
14+
STATIC_REQUIRE(requires { v /= 1; });
15+
STATIC_REQUIRE(requires { v %= 1; });
16+
STATIC_REQUIRE(requires { v &= 1; });
17+
STATIC_REQUIRE(requires { v |= 1; });
18+
STATIC_REQUIRE(requires { v ^= 1; });
19+
STATIC_REQUIRE(requires { v <<= 1; });
20+
STATIC_REQUIRE(requires { v >>= 1; });
1221

1322
STATIC_REQUIRE(requires { v + 1; });
1423
STATIC_REQUIRE(requires { v - 1; });
@@ -23,10 +32,8 @@ void arithmetic_test()
2332
}
2433

2534
template<typename T>
26-
void commutative_arithmetic_test()
35+
void commutative_arithmetic_test([[maybe_unused]] T v = {})
2736
{
28-
[[maybe_unused]] T v{};
29-
3037
STATIC_REQUIRE(requires { 1 + v; });
3138
STATIC_REQUIRE(requires { 1 - v; });
3239
STATIC_REQUIRE(requires { 1 * v; });
@@ -40,43 +47,34 @@ void commutative_arithmetic_test()
4047
STATIC_REQUIRE(requires { +v; });
4148
}
4249

43-
SCENARIO("incrementable", "[default operator]")
50+
struct increase_t : increase
4451
{
45-
[[maybe_unused]] struct : increase
46-
{
47-
using increase::operator++;
48-
using increase::operator--;
52+
using increase::operator++;
53+
using increase::operator--;
4954

50-
auto& operator++() { return *this; }
55+
increase_t& operator++();
5156

52-
auto& operator--() { return *this; }
53-
} v{};
57+
increase_t& operator--();
58+
};
5459

55-
STATIC_REQUIRE(requires { v++; });
56-
STATIC_REQUIRE(requires { v--; });
60+
SCENARIO("incrementable", "[default operator]")
61+
{
62+
STATIC_REQUIRE(requires(increase_t v) { v++; });
63+
STATIC_REQUIRE(requires(increase_t v) { v--; });
5764
}
5865

5966
struct arith : arithmetic
6067
{
61-
auto& operator+=(int /*unused*/) { return *this; }
62-
63-
auto& operator-=(int /*unused*/) { return *this; }
64-
65-
auto& operator*=(int /*unused*/) { return *this; }
66-
67-
auto& operator/=(int /*unused*/) { return *this; }
68-
69-
auto& operator%=(int /*unused*/) { return *this; }
70-
71-
auto& operator&=(int /*unused*/) { return *this; }
72-
73-
auto& operator|=(int /*unused*/) { return *this; }
74-
75-
auto& operator^=(int /*unused*/) { return *this; }
76-
77-
auto& operator<<=(int /*unused*/) { return *this; }
78-
79-
auto& operator>>=(int /*unused*/) { return *this; }
68+
arith& operator+=(int);
69+
arith& operator-=(int);
70+
arith& operator*=(int);
71+
arith& operator/=(int);
72+
arith& operator%=(int);
73+
arith& operator&=(int);
74+
arith& operator|=(int);
75+
arith& operator^=(int);
76+
arith& operator<<=(int);
77+
arith& operator>>=(int);
8078
};
8179

8280
SCENARIO("arithmetic", "[default operator]") { arithmetic_test<arith>(); }
@@ -138,15 +136,15 @@ SCENARIO("arrow", "[default operator]")
138136

139137
// TODO: multidimensional subscript
140138
#if __cpp_multidimensional_subscript >= 202110L
141-
SCENARIO("subscript", "[default operator]")
139+
struct subscript_t : subscript
142140
{
143-
[[maybe_unused]] struct : subscript
144-
{
145-
using subscript::operator[];
141+
using subscript::operator[];
146142

147-
[[nodiscard]] auto operator[](const int /*unused*/) const { return *this; }
148-
} v{};
143+
subscript_t operator[](int) const;
144+
};
149145

150-
STATIC_REQUIRE(requires { v[0, 1]; });
146+
SCENARIO("subscript", "[default operator]")
147+
{
148+
STATIC_REQUIRE(requires(subscript_t v) { v[0, 1]; });
151149
}
152150
#endif

tests/src/type_traits/type_sequence.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ SCENARIO("type sequence apply", "[type traits][type sequence]")
3030

3131
namespace
3232
{
33-
inline constexpr auto type_sequence_invoker = []<typename T>(const basic_type_constant<T>) {};
33+
struct type_sequence_invoker
34+
{
35+
template<typename T>
36+
constexpr void operator()(const basic_type_constant<T> /*unused*/)
37+
{
38+
}
39+
};
3440
}
3541

3642
TEMPLATE_TEST_CASE(
3743
"Scenario: type sequence invoke",
3844
"[type traits][type sequence]",
3945
identity,
40-
decltype(type_sequence_invoker)
46+
type_sequence_invoker
4147
)
4248
{
4349
STATIC_REQUIRE(invocable<test_seq::invoke_fn<>, TestType>);
@@ -49,9 +55,9 @@ TEMPLATE_TEST_CASE_SIG(
4955
"Scenario: type sequence find",
5056
"[type traits][type sequence]",
5157
((typename T, auto Expect), T, Expect),
52-
(int, 0) //,
53-
// (float, 1),
54-
// (void, test_seq::size())
58+
(int, 0),
59+
(float, 1),
60+
(void, test_seq::size())
5561
)
5662
{
5763
STATIC_REQUIRE(
@@ -73,7 +79,7 @@ TEMPLATE_TEST_CASE_SIG(
7379
);
7480
}
7581

76-
TEMPLATE_TEST_CASE_SIG(
82+
TEMPLATE_TEST_CASE_SIG(
7783
"Scenario: type sequence append",
7884
"[type traits][type sequence]",
7985
( //
@@ -102,7 +108,7 @@ TEMPLATE_TEST_CASE_SIG(
102108
STATIC_REQUIRE(same_as<test_seq::append_front_t<T...>, FrontExpect>);
103109
}
104110

105-
TEMPLATE_TEST_CASE_SIG(
111+
TEMPLATE_TEST_CASE_SIG(
106112
"Scenario: type sequence insert",
107113
"[type traits][type sequence]",
108114
((auto Index, typename Expect, typename... T), Index, Expect, T...),

0 commit comments

Comments
 (0)