Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Aug 31, 2024
1 parent c8abf94 commit 9117ec4
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions tests/example_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,37 @@ constexpr double constexptest() { return parse("3.1415 input"); }
#endif

bool small() {
double result = -1;
std::string str = "3e-1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if(r.ec != std::errc::result_out_of_range) { return false; }
if(r.ptr != str.data() + 7) { return false; }
if(result != 0) { return false; }
double result = -1;
std::string str = "3e-1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if (r.ec != std::errc::result_out_of_range) {
return false;
}
if (r.ptr != str.data() + 7) {
return false;
}
if (result != 0) {
return false;
}
printf("small values go to zero\n");
return true;
return true;
}

bool large() {
double result = -1;
std::string str = "3e1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if(r.ec != std::errc::result_out_of_range) { return false; }
if(r.ptr != str.data() + 6) { return false; }
if(result != std::numeric_limits<double>::infinity()) { return false; }
double result = -1;
std::string str = "3e1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if (r.ec != std::errc::result_out_of_range) {
return false;
}
if (r.ptr != str.data() + 6) {
return false;
}
if (result != std::numeric_limits<double>::infinity()) {
return false;
}
printf("large values go to infinity\n");
return true;
return true;
}

int main() {
Expand Down

0 comments on commit 9117ec4

Please sign in to comment.