2020-10-09 16:22:29 -04:00
|
|
|
set(AK_TEST_SOURCES
|
|
|
|
|
TestAllOf.cpp
|
2021-01-14 15:36:23 -07:00
|
|
|
TestAnyOf.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestArray.cpp
|
|
|
|
|
TestAtomic.cpp
|
2021-01-14 11:12:44 -07:00
|
|
|
TestBadge.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestBase64.cpp
|
2021-03-03 23:05:34 +02:00
|
|
|
TestBinaryHeap.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestBinarySearch.cpp
|
2021-03-22 21:25:06 +03:00
|
|
|
TestBitCast.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestBitmap.cpp
|
2023-01-25 20:06:16 +01:00
|
|
|
TestBitStream.cpp
|
2021-12-12 16:52:57 -06:00
|
|
|
TestBuiltinWrappers.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestByteBuffer.cpp
|
2023-12-16 17:49:34 +03:30
|
|
|
TestByteString.cpp
|
2021-06-01 16:14:01 +02:00
|
|
|
TestCharacterTypes.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestChecked.cpp
|
2022-12-08 22:44:46 +01:00
|
|
|
TestCircularBuffer.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestCircularQueue.cpp
|
2025-06-04 19:43:17 +02:00
|
|
|
TestDemangle.cpp
|
2021-09-13 23:38:42 +04:30
|
|
|
TestDisjointChunks.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestDistinctNumeric.cpp
|
2020-12-24 11:23:12 -07:00
|
|
|
TestDoublyLinkedList.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestEndian.cpp
|
2021-03-06 19:25:33 -08:00
|
|
|
TestEnumBits.cpp
|
2024-03-10 20:52:50 -04:00
|
|
|
TestEnumerate.cpp
|
2020-12-23 11:35:01 -07:00
|
|
|
TestFind.cpp
|
2021-07-11 17:16:13 +02:00
|
|
|
TestFixedArray.cpp
|
2022-12-16 12:42:10 -07:00
|
|
|
TestFixedPoint.cpp
|
2023-01-11 08:26:49 -05:00
|
|
|
TestFlyString.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestFormat.cpp
|
2021-04-21 21:19:39 -06:00
|
|
|
TestGenericLexer.cpp
|
2025-01-07 16:04:26 +01:00
|
|
|
TestGenericShorthands.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestHashFunctions.cpp
|
|
|
|
|
TestHashMap.cpp
|
2021-04-01 20:38:56 -05:00
|
|
|
TestHashTable.cpp
|
2021-04-18 11:06:36 -06:00
|
|
|
TestHex.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestIPv4Address.cpp
|
2022-02-18 20:11:02 -07:00
|
|
|
TestIPv6Address.cpp
|
2021-01-14 11:12:44 -07:00
|
|
|
TestIndexSequence.cpp
|
2022-03-25 17:06:11 +01:00
|
|
|
TestInsertionSort.cpp
|
2022-01-27 13:22:23 +01:00
|
|
|
TestIntegerMath.cpp
|
2021-04-19 22:47:06 -07:00
|
|
|
TestIntrusiveList.cpp
|
2021-04-10 17:59:24 +03:00
|
|
|
TestIntrusiveRedBlackTree.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestJSON.cpp
|
2021-05-30 12:49:39 -06:00
|
|
|
TestLEB128.cpp
|
2022-03-12 21:15:57 -08:00
|
|
|
TestMemory.cpp
|
2023-01-25 20:19:05 +01:00
|
|
|
TestMemoryStream.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestNeverDestroyed.cpp
|
2023-04-21 13:36:32 +02:00
|
|
|
TestNonnullOwnPtr.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestNonnullRefPtr.cpp
|
|
|
|
|
TestNumberFormat.cpp
|
|
|
|
|
TestOptional.cpp
|
2024-02-05 21:47:09 +01:00
|
|
|
TestOptionParser.cpp
|
2022-12-15 20:51:55 -07:00
|
|
|
TestOwnPtr.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestQueue.cpp
|
|
|
|
|
TestQuickSort.cpp
|
2021-04-07 02:11:37 +03:00
|
|
|
TestRedBlackTree.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestRefPtr.cpp
|
2023-12-30 20:07:29 +01:00
|
|
|
TestSegmentedVector.cpp
|
2023-02-17 17:06:03 +01:00
|
|
|
TestSIMD.cpp
|
2021-01-10 11:27:41 -07:00
|
|
|
TestSinglyLinkedList.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestSourceGenerator.cpp
|
2021-04-23 22:26:53 -07:00
|
|
|
TestSourceLocation.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestSpan.cpp
|
2021-05-11 21:47:48 +10:00
|
|
|
TestStack.cpp
|
2021-08-28 11:19:21 -04:00
|
|
|
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
|
2025-06-26 19:06:46 -04:00
|
|
|
TestStringConversions.cpp
|
2022-10-25 14:00:49 -04:00
|
|
|
TestStringFloatingPointConversions.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestStringUtils.cpp
|
|
|
|
|
TestStringView.cpp
|
2025-06-19 20:04:44 +02:00
|
|
|
TestTime.cpp
|
2020-12-26 13:52:44 +03:30
|
|
|
TestTrie.cpp
|
2021-05-09 08:24:22 +04:30
|
|
|
TestTuple.cpp
|
2020-12-29 22:44:59 -07:00
|
|
|
TestTypeTraits.cpp
|
2021-01-14 11:12:44 -07:00
|
|
|
TestTypedTransfer.cpp
|
2021-05-19 23:04:48 +02:00
|
|
|
TestUFixedBigInt.cpp
|
2025-06-20 11:52:35 -04:00
|
|
|
TestUtf16FlyString.cpp
|
2025-06-12 19:29:41 -04:00
|
|
|
TestUtf16String.cpp
|
2025-06-13 07:04:47 -04:00
|
|
|
TestUtf16View.cpp
|
|
|
|
|
TestUtf8View.cpp
|
2021-04-26 01:34:10 +04:30
|
|
|
TestVariant.cpp
|
2020-10-09 16:22:29 -04:00
|
|
|
TestVector.cpp
|
|
|
|
|
TestWeakPtr.cpp
|
|
|
|
|
)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2025-05-19 16:16:18 -07:00
|
|
|
# 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)
|
2025-06-04 19:43:17 +02:00
|
|
|
else()
|
|
|
|
|
list(APPEND AK_TEST_SOURCES TestDelayLoadWindows.cpp)
|
2025-05-19 16:16:18 -07:00
|
|
|
endif()
|
|
|
|
|
|
2021-09-01 23:44:24 -06:00
|
|
|
foreach(source IN LISTS AK_TEST_SOURCES)
|
2025-06-30 08:11:44 -07:00
|
|
|
ladybird_test("${source}" AK)
|
2020-05-06 18:40:06 +03:00
|
|
|
endforeach()
|
2023-01-08 16:33:30 -05:00
|
|
|
|
2025-05-19 16:16:18 -07:00
|
|
|
if (WIN32)
|
|
|
|
|
# FIXME: Windows on ARM
|
|
|
|
|
target_link_libraries(TestUFixedBigInt PRIVATE clang_rt.builtins-x86_64.lib)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-03-16 17:35:38 -06:00
|
|
|
if (CXX_COMPILER_SUPPORTS_BLOCKS)
|
2025-06-30 08:11:44 -07:00
|
|
|
ladybird_test(TestFunction.mm AK NAME TestFunction)
|
2025-03-16 17:35:38 -06:00
|
|
|
target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES})
|
|
|
|
|
endif()
|
|
|
|
|
if (CXX_COMPILER_SUPPORTS_OBJC_ARC)
|
2025-06-30 08:11:44 -07:00
|
|
|
ladybird_test(TestFunction.mm AK NAME TestFunctionArc)
|
2025-03-16 17:35:38 -06:00
|
|
|
target_compile_options(TestFunctionArc PRIVATE -fobjc-arc)
|
|
|
|
|
target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES})
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-01-08 16:33:30 -05:00
|
|
|
target_link_libraries(TestString PRIVATE LibUnicode)
|
2025-07-25 09:33:08 -04:00
|
|
|
target_link_libraries(TestUtf16String PRIVATE LibUnicode)
|
2024-08-17 12:53:39 -06:00
|
|
|
|
|
|
|
|
if (ENABLE_SWIFT)
|
2024-08-27 01:57:13 -06:00
|
|
|
|
|
|
|
|
# FIXME: Convert to use swift-testing after resolving https://github.com/LadybirdBrowser/ladybird/issues/1201
|
2024-08-17 12:53:39 -06:00
|
|
|
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()
|