ladybird/Tests/AK/CMakeLists.txt
davidot 53b7f5e6a1 AK: Add an exact and fast floating point parsing algorithm
This is based on the paper by Daniel Lemire called
"Number parsing at a Gigabyte per second", currently available at
https://arxiv.org/abs/2101.11408
An implementation can be found at
https://github.com/fastfloat/fast_float

To support both strtod like methods and String::to_double we have two
different APIs. The parse_first_floating_point gives back both the
result, next character to read and the error/out of range status.
Out of range here means we rounded to infinity 0.

The other API, parse_floating_point_completely, will return a floating
point only if the given character range contains just the floating point
and nothing else. This can be much faster as we can skip actually
computing the value if we notice we did not parse the whole range.

Both of these APIs support a very lenient format to be usable in as many
places as possible. Also it does not check for "named" values like
"nan", "inf", "NAN" etc. Because this can be different for every usage.

For integers and small values this new method is not faster and often
even a tiny bit slower than the current strtod implementation. However
the strtod implementation is wrong for a lot of values and has a much
less predictable running time.

For correctness this method was tested against known string -> double
datasets from https://github.com/nigeltao/parse-number-fxx-test-data
This method gives 100% accuracy.
The old strtod gave an incorrect value in over 50% of the numbers
tested.
2022-10-23 15:48:45 +02:00

84 lines
1.8 KiB
CMake

set(AK_TEST_SOURCES
TestFixedPoint.cpp
TestAllOf.cpp
TestAnyOf.cpp
TestArbitrarySizedEnum.cpp
TestArray.cpp
TestAtomic.cpp
TestBadge.cpp
TestBase64.cpp
TestBinaryHeap.cpp
TestBinarySearch.cpp
TestBitCast.cpp
TestBitmap.cpp
TestBuiltinWrappers.cpp
TestByteBuffer.cpp
TestCharacterTypes.cpp
TestChecked.cpp
TestCircularDeque.cpp
TestCircularDuplexStream.cpp
TestCircularQueue.cpp
TestComplex.cpp
TestDisjointChunks.cpp
TestDistinctNumeric.cpp
TestDoublyLinkedList.cpp
TestEndian.cpp
TestEnumBits.cpp
TestFind.cpp
TestFixedArray.cpp
TestFloatingPoint.cpp
TestFloatingPointParsing.cpp
TestFormat.cpp
TestGenericLexer.cpp
TestHashFunctions.cpp
TestHashMap.cpp
TestHashTable.cpp
TestHex.cpp
TestIPv4Address.cpp
TestIPv6Address.cpp
TestIndexSequence.cpp
TestIntegerMath.cpp
TestIntrusiveList.cpp
TestIntrusiveRedBlackTree.cpp
TestJSON.cpp
TestLEB128.cpp
TestLexicalPath.cpp
TestMACAddress.cpp
TestMemory.cpp
TestMemoryStream.cpp
TestNeverDestroyed.cpp
TestNonnullRefPtr.cpp
TestNumberFormat.cpp
TestOptional.cpp
TestPrint.cpp
TestQueue.cpp
TestQuickSort.cpp
TestRedBlackTree.cpp
TestRefPtr.cpp
TestSinglyLinkedList.cpp
TestSourceGenerator.cpp
TestSourceLocation.cpp
TestSpan.cpp
TestStack.cpp
TestStdLibExtras.cpp
TestString.cpp
TestStringUtils.cpp
TestStringView.cpp
TestTime.cpp
TestTrie.cpp
TestTuple.cpp
TestTypeTraits.cpp
TestTypedTransfer.cpp
TestUFixedBigInt.cpp
TestURL.cpp
TestUtf16.cpp
TestUtf8.cpp
TestVariant.cpp
TestVector.cpp
TestWeakPtr.cpp
)
foreach(source IN LISTS AK_TEST_SOURCES)
serenity_test("${source}" AK)
endforeach()