diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5f1947d..223c9e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,7 +9,7 @@ option(SYSTEM_DOCTEST "Use system copy of doctest" OFF) if (NOT SYSTEM_DOCTEST) FetchContent_Declare(doctest GIT_REPOSITORY https://github.com/onqtam/doctest.git - GIT_TAG v2.4.9) + GIT_TAG v2.4.10) endif() FetchContent_Declare(supplemental_test_files GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git @@ -83,3 +83,4 @@ if (FASTFLOAT_EXHAUSTIVE) endif(FASTFLOAT_EXHAUSTIVE) add_subdirectory(build_tests) +add_subdirectory(bloat_analysis) diff --git a/tests/bloat_analysis/CMakeLists.txt b/tests/bloat_analysis/CMakeLists.txt new file mode 100644 index 0000000..435f485 --- /dev/null +++ b/tests/bloat_analysis/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(bloaty main.cpp a1.cpp a2.cpp a3.cpp a4.cpp a4.cpp a5.cpp a6.cpp a7.cpp a8.cpp a9.cpp a10.cpp) +target_link_libraries(bloaty PUBLIC fast_float) + +add_executable(bloatyref main_ref.cpp) +target_link_libraries(bloatyref PUBLIC fast_float) \ No newline at end of file diff --git a/tests/bloat_analysis/a1.cpp b/tests/bloat_analysis/a1.cpp new file mode 100644 index 0000000..a35e093 --- /dev/null +++ b/tests/bloat_analysis/a1.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get1(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 1; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a10.cpp b/tests/bloat_analysis/a10.cpp new file mode 100644 index 0000000..a1104a1 --- /dev/null +++ b/tests/bloat_analysis/a10.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get10(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 10; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a2.cpp b/tests/bloat_analysis/a2.cpp new file mode 100644 index 0000000..7eee8a2 --- /dev/null +++ b/tests/bloat_analysis/a2.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get2(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 2; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a3.cpp b/tests/bloat_analysis/a3.cpp new file mode 100644 index 0000000..054048c --- /dev/null +++ b/tests/bloat_analysis/a3.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get3(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 3; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a4.cpp b/tests/bloat_analysis/a4.cpp new file mode 100644 index 0000000..7d182eb --- /dev/null +++ b/tests/bloat_analysis/a4.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get4(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 4; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a5.cpp b/tests/bloat_analysis/a5.cpp new file mode 100644 index 0000000..488c526 --- /dev/null +++ b/tests/bloat_analysis/a5.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get5(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 5; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a6.cpp b/tests/bloat_analysis/a6.cpp new file mode 100644 index 0000000..f063541 --- /dev/null +++ b/tests/bloat_analysis/a6.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get6(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 6; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a7.cpp b/tests/bloat_analysis/a7.cpp new file mode 100644 index 0000000..34424ad --- /dev/null +++ b/tests/bloat_analysis/a7.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get7(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 7; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a8.cpp b/tests/bloat_analysis/a8.cpp new file mode 100644 index 0000000..316104b --- /dev/null +++ b/tests/bloat_analysis/a8.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get8(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 8; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/a9.cpp b/tests/bloat_analysis/a9.cpp new file mode 100644 index 0000000..8941084 --- /dev/null +++ b/tests/bloat_analysis/a9.cpp @@ -0,0 +1,9 @@ +#include "fast_float/fast_float.h" + + +double get9(const char* input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 9; } + return result_value; +} \ No newline at end of file diff --git a/tests/bloat_analysis/main.cpp b/tests/bloat_analysis/main.cpp new file mode 100644 index 0000000..60f26fc --- /dev/null +++ b/tests/bloat_analysis/main.cpp @@ -0,0 +1,19 @@ + + +double get1(const char* input); +double get2(const char* input); +double get3(const char* input); +double get4(const char* input); +double get5(const char* input); +double get6(const char* input); +double get7(const char* input); +double get8(const char* input); +double get9(const char* input); +double get10(const char* input); + +int main(int arg, char** argv) { + double x = get1(argv[0]) + get2(argv[0]) + get3(argv[0]) + get4(argv[0]) + get5(argv[0]) + + get6(argv[0]) + get7(argv[0]) + get8(argv[0]) + get9(argv[0]) + get10(argv[0]); + + return int(x); +} \ No newline at end of file diff --git a/tests/bloat_analysis/main_ref.cpp b/tests/bloat_analysis/main_ref.cpp new file mode 100644 index 0000000..80c8cb2 --- /dev/null +++ b/tests/bloat_analysis/main_ref.cpp @@ -0,0 +1,13 @@ +#include "fast_float/fast_float.h" + +double get(const char * input) { + double result_value; + auto result = fast_float::from_chars(input, input + strlen(input), result_value); + if (result.ec != std::errc()) { return 10; } + return result_value; +} + +int main(int arg, char** argv) { + double x = get(argv[0]); + return int(x); +} \ No newline at end of file