ladybird/Tests/AK/CMakeLists.txt

126 lines
3.3 KiB
Text
Raw Normal View History

set(AK_TEST_SOURCES
TestAllOf.cpp
TestAnyOf.cpp
TestArray.cpp
TestAtomic.cpp
TestBadge.cpp
TestBase64.cpp
TestBinaryHeap.cpp
TestBinarySearch.cpp
2021-03-22 21:25:06 +03:00
TestBitCast.cpp
TestBitmap.cpp
2023-01-25 20:06:16 +01:00
TestBitStream.cpp
TestBuiltinWrappers.cpp
TestByteBuffer.cpp
TestByteString.cpp
TestCharacterTypes.cpp
TestChecked.cpp
TestCircularBuffer.cpp
TestCircularQueue.cpp
TestDemangle.cpp
TestDisjointChunks.cpp
TestDistinctNumeric.cpp
TestDoublyLinkedList.cpp
TestEndian.cpp
TestEnumBits.cpp
TestEnumerate.cpp
TestFind.cpp
TestFixedArray.cpp
TestFixedPoint.cpp
TestFlyString.cpp
TestFormat.cpp
TestGenericLexer.cpp
2025-01-07 16:04:26 +01:00
TestGenericShorthands.cpp
TestHashFunctions.cpp
TestHashMap.cpp
2021-04-01 20:38:56 -05:00
TestHashTable.cpp
TestHex.cpp
TestIPv4Address.cpp
TestIPv6Address.cpp
TestIndexSequence.cpp
TestInsertionSort.cpp
TestIntegerMath.cpp
TestIntrusiveList.cpp
TestIntrusiveRedBlackTree.cpp
TestJSON.cpp
2021-05-30 12:49:39 -06:00
TestLEB128.cpp
TestMemory.cpp
2023-01-25 20:19:05 +01:00
TestMemoryStream.cpp
TestNeverDestroyed.cpp
TestNonnullOwnPtr.cpp
TestNonnullRefPtr.cpp
TestNumberFormat.cpp
TestOptional.cpp
TestOptionParser.cpp
TestOwnPtr.cpp
TestQueue.cpp
TestQuickSort.cpp
TestRedBlackTree.cpp
TestRefPtr.cpp
TestSegmentedVector.cpp
TestSIMD.cpp
TestSinglyLinkedList.cpp
TestSourceGenerator.cpp
TestSourceLocation.cpp
TestSpan.cpp
2021-05-11 21:47:48 +10:00
TestStack.cpp
TestStdLibExtras.cpp
AK: Introduce the new String, replacement for DeprecatedString DeprecatedString (formerly String) has been with us since the start, and it has served us well. However, it has a number of shortcomings that I'd like to address. Some of these issues are hard if not impossible to solve incrementally inside of DeprecatedString, so instead of doing that, let's build a new String class and then incrementally move over to it instead. Problems in DeprecatedString: - It assumes string allocation never fails. This makes it impossible to use in allocation-sensitive contexts, and is the reason we had to ban DeprecatedString from the kernel entirely. - The awkward null state. DeprecatedString can be null. It's different from the empty state, although null strings are considered empty. All code is immediately nicer when using Optional<DeprecatedString> but DeprecatedString came before Optional, which is how we ended up like this. - The encoding of the underlying data is ambiguous. For the most part, we use it as if it's always UTF-8, but there have been cases where we pass around strings in other encodings (e.g ISO8859-1) - operator[] and length() are used to iterate over DeprecatedString one byte at a time. This is done all over the codebase, and will *not* give the right results unless the string is all ASCII. How we solve these issues in the new String: - Functions that may allocate now return ErrorOr<String> so that ENOMEM errors can be passed to the caller. - String has no null state. Use Optional<String> when needed. - String is always UTF-8. This is validated when constructing a String. We may need to add a bypass for this in the future, for cases where you have a known-good string, but for now: validate all the things! - There is no operator[] or length(). You can get the underlying data with bytes(), but for iterating over code points, you should be using an UTF-8 iterator. Furthermore, it has two nifty new features: - String implements a small string optimization (SSO) for strings that can fit entirely within a pointer. This means up to 3 bytes on 32-bit platforms, and 7 bytes on 64-bit platforms. Such small strings will not be heap-allocated. - String can create substrings without making a deep copy of the substring. Instead, the superstring gets +1 refcount from the substring, and it acts like a view into the superstring. To make substrings like this, use the substring_with_shared_superstring() API. One caveat: - String does not guarantee that the underlying data is null-terminated like DeprecatedString does today. While this was nifty in a handful of places where we were calling C functions, it did stand in the way of shared-superstring substrings.
2022-12-01 13:27:43 +01:00
TestString.cpp
TestStringConversions.cpp
TestStringFloatingPointConversions.cpp
TestStringUtils.cpp
TestStringView.cpp
TestTime.cpp
TestTrie.cpp
TestTuple.cpp
TestTypeTraits.cpp
TestTypedTransfer.cpp
TestUFixedBigInt.cpp
TestUtf16FlyString.cpp
TestUtf16String.cpp
TestUtf16View.cpp
TestUtf8View.cpp
TestVariant.cpp
TestVector.cpp
TestWeakPtr.cpp
)
# FIXME: LexicalPathWindows has some parenting and path parts sizing inconsistencies with LexicalPath, so it deserves
# it's own platform-specific tests to avoid if-def soup in the Unix-based tests.
if(NOT WIN32)
list(APPEND AK_TEST_SOURCES TestLexicalPath.cpp)
else()
list(APPEND AK_TEST_SOURCES TestDelayLoadWindows.cpp)
endif()
foreach(source IN LISTS AK_TEST_SOURCES)
ladybird_test("${source}" AK)
endforeach()
if (WIN32)
# FIXME: Windows on ARM
target_link_libraries(TestUFixedBigInt PRIVATE clang_rt.builtins-x86_64.lib)
endif()
if (CXX_COMPILER_SUPPORTS_BLOCKS)
ladybird_test(TestFunction.mm AK NAME TestFunction)
target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES})
endif()
if (CXX_COMPILER_SUPPORTS_OBJC_ARC)
ladybird_test(TestFunction.mm AK NAME TestFunctionArc)
target_compile_options(TestFunctionArc PRIVATE -fobjc-arc)
target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES})
endif()
target_link_libraries(TestString PRIVATE LibUnicode)
target_link_libraries(TestUtf16String PRIVATE LibUnicode)
if (ENABLE_SWIFT)
# FIXME: Convert to use swift-testing after resolving https://github.com/LadybirdBrowser/ladybird/issues/1201
add_executable(TestAKBindings TestAKBindings.swift)
target_link_libraries(TestAKBindings PRIVATE AK)
target_compile_options(TestAKBindings PRIVATE -parse-as-library)
add_test(NAME TestAKBindings COMMAND TestAKBindings)
endif()