Skip to content

Commit

Permalink
Test convertibles in std::isinf()
Browse files Browse the repository at this point in the history
  • Loading branch information
robincaloudis committed Jul 15, 2024
1 parent 93d2b23 commit 0f97ac1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libcxx/test/std/numerics/c.math/isinf.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,30 @@ struct TestInt {
}
};

struct ConvertibleFloat {
int value;
ConvertibleFloat(int v) : value(v) {}
operator float() const { return static_cast<float>(value); }
};

struct ConvertibleDouble {
int value;
ConvertibleDouble(int v) : value(v) {}
operator double() const { return static_cast<double>(value); }
};

struct ConvertibleLongDouble {
int value;
ConvertibleLongDouble(int v) : value(v) {}
operator long double() const { return static_cast<long double>(value); }
};

int main(int, char**) {
types::for_each(types::floating_point_types(), TestFloat());
types::for_each(types::integral_types(), TestInt());
assert(!std::isinf(ConvertibleFloat(0)));
assert(!std::isinf(ConvertibleDouble(0)));
assert(!std::isinf(ConvertibleLongDouble(0)));

return 0;
}

0 comments on commit 0f97ac1

Please sign in to comment.