1- #include < gtest/gtest.h>
2- #include < type_traits>
31#include < atomic>
42#include < cstdint>
3+ #include < gtest/gtest.h>
54#include < thread>
5+ #include < type_traits>
66#include < vector>
77
8+
89import mcpplibs.primitives;
910
1011using namespace mcpplibs ::primitives;
@@ -23,7 +24,8 @@ TEST(OperationsTest, AddReturnsExpectedPrimitive) {
2324}
2425
2526TEST (OperationsTest, DivisionByZeroReturnsError) {
26- using value_t = primitive<int , policy::value::checked, policy::error::expected>;
27+ using value_t =
28+ primitive<int , policy::value::checked, policy::error::expected>;
2729
2830 auto const lhs = value_t {100 };
2931 auto const rhs = value_t {0 };
@@ -60,8 +62,8 @@ TEST(OperationsTest, CheckedAdditionReportsUnsignedOverflow) {
6062}
6163
6264TEST (OperationsTest, UncheckedAdditionWrapsUnsignedOverflow) {
63- using value_t =
64- primitive<std:: uint16_t , policy::value::unchecked, policy::error::expected>;
65+ using value_t = primitive<std:: uint16_t , policy::value::unchecked,
66+ policy::error::expected>;
6567
6668 auto const lhs = value_t {static_cast <std::uint16_t >(65530 )};
6769 auto const rhs = value_t {static_cast <std::uint16_t >(20 )};
@@ -86,8 +88,9 @@ TEST(OperationsTest, UncheckedDivisionUsesRawArithmeticWhenValid) {
8688}
8789
8890TEST (OperationsTest, AtomicPolicyPathReturnsExpectedValue) {
89- using value_t = primitive<int , policy::value::checked, policy::concurrency::atomic,
90- policy::error::expected>;
91+ using value_t =
92+ primitive<int , policy::value::checked, policy::concurrency::atomic,
93+ policy::error::expected>;
9194
9295 auto const lhs = value_t {12 };
9396 auto const rhs = value_t {30 };
@@ -99,8 +102,9 @@ TEST(OperationsTest, AtomicPolicyPathReturnsExpectedValue) {
99102}
100103
101104TEST (OperationsTest, AtomicPolicyConcurrentInvocationsRemainConsistent) {
102- using value_t = primitive<int , policy::value::checked, policy::concurrency::atomic,
103- policy::error::expected>;
105+ using value_t =
106+ primitive<int , policy::value::checked, policy::concurrency::atomic,
107+ policy::error::expected>;
104108
105109 constexpr int kThreadCount = 8 ;
106110 constexpr int kIterationsPerThread = 20000 ;
@@ -147,8 +151,8 @@ TEST(OperationsTest, AtomicPolicyConcurrentInvocationsRemainConsistent) {
147151TEST (OperationsTest, StrictTypeRejectsMixedTypesAtCompileTime) {
148152 using lhs_t = primitive<int , policy::value::checked, policy::type::strict,
149153 policy::error::expected>;
150- using rhs_t = primitive<long long , policy::value::checked, policy::type::strict,
151- policy::error::expected>;
154+ using rhs_t = primitive<long long , policy::value::checked,
155+ policy::type::strict, policy:: error::expected>;
152156
153157 using strict_handler =
154158 policy::type::handler<policy::type::strict, operations::Addition, int ,
@@ -201,7 +205,7 @@ TEST(OperationsTest, CharUnderlyingRejectsArithmeticEvenWithTransparentType) {
201205
202206 static_assert (char_handler::enabled);
203207 static_assert (!char_handler::allowed);
204- static_assert (std::is_same_v<typename char_meta::common_rep, char >);
208+ static_assert (std::is_same_v<typename char_meta::common_rep, void >);
205209
206210 EXPECT_EQ (char_handler::diagnostic_id, 3u );
207211}
@@ -312,7 +316,8 @@ TEST(OperationsTest, OperatorPlusDelegatesToDispatcher) {
312316}
313317
314318TEST (OperationsTest, ThrowErrorPolicyThrowsException) {
315- using value_t = primitive<int , policy::value::checked, policy::error::throwing>;
319+ using value_t =
320+ primitive<int , policy::value::checked, policy::error::throwing>;
316321
317322 auto const lhs = value_t {100 };
318323 auto const rhs = value_t {0 };
@@ -321,7 +326,8 @@ TEST(OperationsTest, ThrowErrorPolicyThrowsException) {
321326}
322327
323328TEST (OperationsTest, ThrowErrorPolicyExceptionHasReasonMessage) {
324- using value_t = primitive<int , policy::value::checked, policy::error::throwing>;
329+ using value_t =
330+ primitive<int , policy::value::checked, policy::error::throwing>;
325331
326332 auto const lhs = value_t {100 };
327333 auto const rhs = value_t {0 };
0 commit comments