Skip to content

Commit 21821f5

Browse files
authored
[libc] Update floating testing infra for MSVC compatibility. (#159810)
1 parent 2e34188 commit 21821f5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

libc/test/UnitTest/FEnvSafeTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv,
5151
EXPECT_EQ(before_state.ControlWord, after_state.ControlWord);
5252
EXPECT_EQ(before_state.StatusWord, after_state.StatusWord);
5353

54-
#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__)
54+
#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__) && \
55+
!defined(LIBC_COMPILER_IS_MSVC)
5556
using LIBC_NAMESPACE::fputil::internal::FPState;
5657
const FPState &before_state = reinterpret_cast<const FPState &>(before_fenv);
5758
const FPState &after_state = reinterpret_cast<const FPState &>(after_fenv);

libc/test/UnitTest/FPMatcher.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
125125

126126
bool match(T actualValue) {
127127
actual = actualValue;
128+
#ifndef LIBC_COMPILER_IS_MSVC
128129
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
129130
return matchComplex<float>();
130131
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
@@ -134,14 +135,18 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
134135
#ifdef LIBC_TYPES_HAS_CFLOAT16
135136
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
136137
return matchComplex<float16>();
137-
#endif
138+
#endif // LIBC_TYPES_HAS_CFLOAT16
138139
#ifdef LIBC_TYPES_HAS_CFLOAT128
139140
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
140141
return matchComplex<float128>();
141-
#endif
142+
#endif // LIBC_TYPES_HAS_CFLOAT128
143+
#else // LIBC_COMPILER_IS_MSVC
144+
return true;
145+
#endif // LIBC_COMPILER_IS_MSVC
142146
}
143147

144148
void explainError() override {
149+
#ifndef LIBC_COMPILER_IS_MSVC
145150
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
146151
return explainErrorComplex<float>();
147152
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
@@ -151,11 +156,12 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
151156
#ifdef LIBC_TYPES_HAS_CFLOAT16
152157
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
153158
return explainErrorComplex<float16>();
154-
#endif
159+
#endif // LIBC_TYPES_HAS_CFLOAT16
155160
#ifdef LIBC_TYPES_HAS_CFLOAT128
156161
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
157162
return explainErrorComplex<float128>();
158-
#endif
163+
#endif // LIBC_TYPES_HAS_CFLOAT128
164+
#endif // LIBC_COMPILER_IS_MSVC
159165
}
160166
};
161167

0 commit comments

Comments
 (0)