@@ -30,8 +30,6 @@ MATCHER_P(Result, value, "") // NOLINT(readability-redundant-string-init)
30
30
{
31
31
using namespace fizzy ;
32
32
33
- static_assert (is_any_of<value_type, uint32_t , int32_t , uint64_t , int64_t , float , double >);
34
-
35
33
// Require the arg to be TypedExecutionResult.
36
34
// This can be a static_assert, but just returning false and failing a test provides better
37
35
// location of the error.
@@ -44,24 +42,37 @@ MATCHER_P(Result, value, "") // NOLINT(readability-redundant-string-init)
44
42
45
43
if constexpr (std::is_same_v<result_type, test::TypedExecutionResult>)
46
44
{
47
- // Type safe checks.
48
- if constexpr (is_any_of<value_type, uint32_t , int32_t >)
45
+ if constexpr (std::is_same_v<value_type, float >)
49
46
{
50
- return arg.type == ValType::i32 && arg.value .i64 == static_cast < uint32_t >( value) ;
47
+ return arg.type == ValType::f32 && arg.value .f32 == test::FP{ value} ;
51
48
}
52
- else if constexpr (is_any_of<value_type, uint64_t , int64_t >)
49
+
50
+ if constexpr (std::is_same_v<value_type, double >)
53
51
{
54
- return arg.type == ValType::i64 && arg.value .i64 == static_cast < uint64_t >( value) ;
52
+ return arg.type == ValType::f64 && arg.value .f64 == test::FP{ value} ;
55
53
}
56
- else if constexpr (std::is_same_v<value_type, float >)
54
+
55
+ if constexpr (std::is_integral_v<value_type> && sizeof (value_type) == sizeof (uint64_t ))
57
56
{
58
- return arg.type == ValType::f32 && arg.value .f32 == test::FP{ value} ;
57
+ return arg.type == ValType::i64 && arg.value .i64 == static_cast < uint64_t >( value) ;
59
58
}
60
- else
59
+
60
+ if constexpr (std::is_integral_v<value_type> && sizeof (value_type) == sizeof (uint32_t ))
61
61
{
62
- return arg.type == ValType::f64 && arg.value .f64 == test::FP{value};
62
+ if (arg.type == ValType::i32)
63
+ {
64
+ return arg.value .i64 == static_cast <uint32_t >(value);
65
+ }
66
+ else if (arg.type == ValType::i64 && value >= 0 )
67
+ {
68
+ // Here allow convenient zero-extension of the expected value u32 -> u64.
69
+ return arg.value .i64 == static_cast <uint32_t >(value);
70
+ }
71
+ return false ;
63
72
}
64
73
}
74
+
75
+ return false ;
65
76
}
66
77
67
78
MATCHER (CTraps, " " ) // NOLINT(readability-redundant-string-init)
0 commit comments