Added basic tests for fast_int in fast_int.cpp#1
Added basic tests for fast_int in fast_int.cpp#1mayawarrier merged 10 commits intomayawarrier:mainfrom
Conversation
…rs, invalid bases, and out of range bases
0b48101 to
3d446f1
Compare
| int result; | ||
| auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result, 100); | ||
| if (answer.ec != std::errc()) { | ||
| std::cerr << "could not convert to int for input: " << std::quoted(f) << std::endl; |
There was a problem hiding this comment.
invalid bases are always rejected with std::errc::invalid_argument, so this test will never succeed.
| } | ||
|
|
||
| // unsigned pointer test #1 (string behind numbers) | ||
| const std::vector<std::string> unsigned_pointer_test_1 { "1001 with text" }; |
There was a problem hiding this comment.
these don't need to be vectors if there's only one element in them
| } | ||
|
|
||
| // int out of range error test | ||
| const std::vector<std::string> int_out_of_range_test{ "2000000000000000000000" }; |
There was a problem hiding this comment.
add some more tests here, especially when the numbers are just outside range (like int_max + 1 or int_min -1). these are a bit tougher to catch
| unsigned basic tests - numbers only, numbers with strings behind, decimals | ||
| int invalid tests - strings only, strings with numbers behind, space in front of number, plus sign in front of number | ||
| unsigned invalid tests - strings only, strings with numbers behind, space in front of number, plus/minus sign in front of number | ||
| int out of range tests - numbers exceeding int bit size (Note: out of range errors for 8, 16, 32, and 64 bits have not been tested) |
There was a problem hiding this comment.
out_of_range was the nastiest to get right and I'm not 100% sure it's correct since I'm using a few handmade lookup tables to do it.
can you add test cases for every base for 64-bit (signed and unsigned)?
…ts, out of range errors for all bases (64 bit only), and fixed some test cases
| "ACD772JNC9L0L8", | ||
| "-ACD772JNC9L0L9", | ||
| "64IE1FOCNN5G78", | ||
| "-64IE1FOCNN5G79", |
There was a problem hiding this comment.
I haven't checked these numbers, but are some of them just outside the range as well (like int64_min - 1 and int64_max + 1)?
|
|
||
| // unsigned base 2 test | ||
| const std::vector<unsigned> unsigned_base_2_test_expected { 0, 1, 4, 2 }; | ||
| const std::vector<std::string> unsigned_base_2_test { "0", "1", "100", "010" }; |
There was a problem hiding this comment.
for every valid test, can you also add cases where the numbers are just within range (like int_min or int_max)
No description provided.