Add ability to convert larger numbers without fast_float, write unit tests

This commit is contained in:
ado
2023-08-08 14:11:51 +02:00
parent b9d2c2aad9
commit 672b89b213
4 changed files with 60 additions and 19 deletions

View File

@@ -1,10 +1,10 @@
#pragma once
#include <ctime>
#include <filesystem>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <filesystem>
#ifdef CMAKE_GITHUB_CI
#include <doctest/doctest.h>
@@ -75,6 +75,18 @@ struct unique_file_name {
CHECK_LT(std::abs(t.value() - type(-input)), eps); \
}
#define CHECK_FLOATING_CONVERSION_LONG_NUMBER(STRING_NUMBER, TYPE, CONVERTER) \
{ \
auto begin = STRING_NUMBER.c_str(); \
auto end = begin + STRING_NUMBER.size(); \
\
auto number = ss::to_num<TYPE>(begin, end); \
REQUIRE(number.has_value()); \
\
auto expected_number = CONVERTER(STRING_NUMBER); \
CHECK_EQ(number.value(), expected_number); \
}
#define CHECK_INVALID_CONVERSION(input, type) \
{ \
std::string s = input; \