return ::testing::AssertionFailure()
<< "expected (" << std::hexfloat << expected << ") != actual (" << actual << ")";
}
};
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double) -> double function like sin(3). template <size_t ULP, typename RT, typename T, size_t N> void DoMathDataTest(data_1_1_t<RT, T> (&data)[N], RT f(T)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT> predicate; for (size_t i = 0; i < N; ++i) {
EXPECT_PRED_FORMAT2(predicate,
data[i].expected, f(data[i].input)) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double) -> int function like ilogb(3). template <size_t ULP, typename T, size_t N> void DoMathDataTest(data_int_1_t<T> (&data)[N], int f(T)) {
fesetenv(FE_DFL_ENV); for (size_t i = 0; i < N; ++i) {
EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double) -> long int function like lrint(3). template <size_t ULP, typename T, size_t N> void DoMathDataTest(data_long_1_t<T> (&data)[N], long f(T)) {
fesetenv(FE_DFL_ENV); for (size_t i = 0; i < N; ++i) {
EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double) -> long long int function like llrint(3). template <size_t ULP, typename T, size_t N> void DoMathDataTest(data_llong_1_t<T> (&data)[N], longlong f(T)) {
fesetenv(FE_DFL_ENV); for (size_t i = 0; i < N; ++i) {
EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the pairs of input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double, double) -> double function like pow(3). template <size_t ULP, typename RT, typename T1, typename T2, size_t N> void DoMathDataTest(data_1_2_t<RT, T1, T2> (&data)[N], RT f(T1, T2)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT> predicate; for (size_t i = 0; i < N; ++i) {
EXPECT_PRED_FORMAT2(predicate,
data[i].expected, f(data[i].input1, data[i].input2)) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the results are within ULP ulps of the expected values. // For testing a (double, double*, double*) -> void function like sincos(3). template <size_t ULP, typename RT1, typename RT2, typename T1, size_t N> void DoMathDataTest(data_2_1_t<RT1, RT2, T1> (&data)[N], void f(T1, RT1*, RT2*)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT1> predicate1;
FpUlpEq<ULP, RT2> predicate2; for (size_t i = 0; i < N; ++i) {
RT1 out1;
RT2 out2;
f(data[i].input, &out1, &out2);
EXPECT_PRED_FORMAT2(predicate1, data[i].expected1, out1) << "Failed on element " << i;
EXPECT_PRED_FORMAT2(predicate2, data[i].expected2, out2) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the results are within ULP ulps of the expected values. // For testing a (double, double*) -> double function like modf(3). template <size_t ULP, typename RT1, typename RT2, typename T1, size_t N> void DoMathDataTest(data_2_1_t<RT1, RT2, T1> (&data)[N], RT1 f(T1, RT2*)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT1> predicate1;
FpUlpEq<ULP, RT2> predicate2; for (size_t i = 0; i < N; ++i) {
RT1 out1;
RT2 out2;
out1 = f(data[i].input, &out2);
EXPECT_PRED_FORMAT2(predicate1, data[i].expected1, out1) << "Failed on element " << i;
EXPECT_PRED_FORMAT2(predicate2, data[i].expected2, out2) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the results are within ULP ulps of the expected values. // For testing a (double, int*) -> double function like frexp(3). template <size_t ULP, typename RT1, typename T1, size_t N> void DoMathDataTest(data_1_int_1_t<RT1, T1> (&data)[N], RT1 f(T1, int*)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT1> predicate1; for (size_t i = 0; i < N; ++i) {
RT1 out1; int out2;
out1 = f(data[i].input, &out2);
EXPECT_PRED_FORMAT2(predicate1, data[i].expected1, out1) << "Failed on element " << i;
EXPECT_EQ(data[i].expected2, out2) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the input values // and asserting that the results are within ULP ulps of the expected values. // For testing a (double, double, int*) -> double function like remquo(3). template <size_t ULP, typename RT1, typename T1, typename T2, size_t N> void DoMathDataTest(data_1_int_2_t<RT1, T1, T2> (&data)[N], RT1 f(T1, T2, int*)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT1> predicate1; for (size_t i = 0; i < N; ++i) {
RT1 out1; int out2;
out1 = f(data[i].input1, data[i].input2, &out2);
EXPECT_PRED_FORMAT2(predicate1, data[i].expected1, out1) << "Failed on element " << i;
EXPECT_EQ(data[i].expected2, out2) << "Failed on element " << i;
}
}
// Runs through the array 'data' applying 'f' to each of the pairs of input values // and asserting that the result is within ULP ulps of the expected value. // For testing a (double, double, double) -> double function like fma(3). template <size_t ULP, typename RT, typename T1, typename T2, typename T3, size_t N> void DoMathDataTest(data_1_3_t<RT, T1, T2, T3> (&data)[N], RT f(T1, T2, T3)) {
fesetenv(FE_DFL_ENV);
FpUlpEq<ULP, RT> predicate; for (size_t i = 0; i < N; ++i) {
EXPECT_PRED_FORMAT2(predicate,
data[i].expected, f(data[i].input1, data[i].input2, data[i].input3)) << "Failed on element " << i;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.