HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
simd_test_utility.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "simd.hpp"
8#include <gtest/gtest.h>
9
10namespace hi { inline namespace v1 { namespace detail {
11
12// The helper function for {ASSERT|EXPECT}_EQ.
13template<typename T, std::size_t N>
14::testing::AssertionResult
15CmpHelperEQ(const char *lhs_expression, const char *rhs_expression, ::hi::simd<T, N> const& lhs, ::hi::simd<T, N> const& rhs)
16{
17 if (equal(lhs, rhs)) {
18 return ::testing::AssertionSuccess();
19 }
20
21 return ::testing::internal::CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
22}
23
24template<typename T, std::size_t N>
25::testing::AssertionResult
26CmpHelperNE(const char *lhs_expression, const char *rhs_expression, ::hi::simd<T, N> const& lhs, ::hi::simd<T, N> const& rhs)
27{
28 if (not equal(lhs, rhs)) {
29 return ::testing::AssertionSuccess();
30 }
31
32 return ::testing::internal::CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
33}
34
35// The helper function for {ASSERT|EXPECT}_EQ.
36template<typename T, std::size_t N>
37::testing::AssertionResult CmpHelperEQ(
38 const char *lhs_expression,
39 const char *rhs_expression,
40 ::hi::native_simd<T, N> const& lhs,
41 ::hi::native_simd<T, N> const& rhs)
42{
43 if (equal(lhs, rhs)) {
44 return ::testing::AssertionSuccess();
45 }
46
47 return ::testing::internal::CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
48}
49
50template<typename T, std::size_t N>
51::testing::AssertionResult CmpHelperNE(
52 const char *lhs_expression,
53 const char *rhs_expression,
54 ::hi::native_simd<T, N> const& lhs,
55 ::hi::native_simd<T, N> const& rhs)
56{
57 if (not equal(lhs, rhs)) {
58 return ::testing::AssertionSuccess();
59 }
60
61 return ::testing::internal::CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
62}
63
64}}} // namespace hi::v1::detail
65
66#define HI_ASSERT_SIMD_EQ(val1, val2) ASSERT_PRED_FORMAT2(hi::detail::CmpHelperEQ, val1, val2)
67#define HI_ASSERT_SIMD_NE(val1, val2) ASSERT_PRED_FORMAT2(hi::detail::CmpHelperNE, val1, val2)
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
A native-SIMD type.
Definition native_simd_utility.hpp:159
T equal(T... args)