summaryrefslogtreecommitdiff
path: root/Tests/AK
AgeCommit message (Collapse)Author
2021-08-09Tests: Add test for String::bijective_base_from()Mandar Kulkarni
2021-08-08LibDebug: Store 64-bit numbers in AttributeValueDaniel Bertalan
This helps us avoid weird truncation issues and fixes a bug on Clang builds where truncation while reading caused the DIE offsets following large LEB128 numbers to be incorrect. This removes the need for the separate `LongUnsignedNumber` type.
2021-08-06AK: Improve the parsing of data urlsTheFightingCatfish
Improve the parsing of data urls in URLParser to bring it more up-to- spec. At the moment, we cannot parse the components of the MIME type since it is represented as a string, but the spec requires it to be parsed as a "MIME type record".
2021-08-01Tests: Remove unused header includesBrian Gianforcaro
2021-07-31Tests: Fix AK/TestJSON.cpp by not relying on disk resourcesBrian Gianforcaro
The following commit broke Tests/AK/TestJSON.cpp as it removed the file that the test loaded from disk to validate JSON parsing. commit ad141a228696d4e0f80add20d3e40a1fa3e82972 Author: Andreas Kling <kling@serenityos.org> Date: Sat Jul 31 15:26:14 2021 +0200 Base: Remove "test.frm" from HackStudio test project Instead of restoring the file, lets just embed a bit of JSON in the test case to avoid using external resources, as they obviously are surprising and make the test less portable across environments.
2021-07-25AK: Create MACAddress from stringbrapru
Previously there was no way to create a MACAddress by passing a direct address as a string. This will allow programs like the arp utility to create a MACAddress instance by user-passed addresses.
2021-07-22AK: Implement {any,all}_of(IterableContainer&&, Predicate)Ali Mohammad Pur
This is a generally nicer-to-use version of the existing {any,all}_of() that doesn't require the user to explicitly provide two iterators. As a bonus, it also allows arbitrary iterators (as opposed to the hard requirement of providing SimpleIterators in the iterator version).
2021-07-22AK: Add a CommonType<Ts...> type traitAli Mohammad Pur
Also adds a simple-ish test for CommonType.
2021-07-22AK: Add Utf16View for decoding UTF-16 stringsTimothy Flynn
Also includes a way to transcode from and to UTF-8 strings.
2021-07-19AK: Use new Formatter for each element in Formatter<Vector<T>>Andrew Kaster
The state of the formatter for the previous element should be thrown away for each iteration. This showed up when trying to format a Vector<String>, since Formatter<StringView> was unhappy about some state that gets set when it's called. Add a test for Formatter<Vector>.
2021-07-18AK: Allow setting both width and precision when formatting a stringTimothy Flynn
2021-07-17AK: Track byte length, rather than code point length, in Utf8View::trimTimothy Flynn
Utf8View::trim uses Utf8View::substring_view to return its result, which requires the input to be a byte offset/length rather than code point length.
2021-07-16AK/Tests: Add test for EnumBits has_any_flag()Timothy
This test will pass when any flag in the mask is present in the value.
2021-07-16AK/Tests: Add test for EnumBits has_flag()Timothy
This test requires that all values in the mask are present in the value as well.
2021-07-15AK: Make JsonParser correctly parse unsigned values larger than u32Ali Mohammad Pur
Prior to this, it'd try to stuff them into an i64, which could fail and give us nothing. Even though this is an extension we've made to JSON, the parser should be able to correctly round-trip from whatever our serialiser has generated.
2021-07-14Tests: Fix compile errors on ClangDaniel Bertalan
Since Clang enables a couple of warnings that we don't have in GCC, these were not caught before. Included fixes: - Use correct printf format string for `size_t` - Don't compare Nonnull(Ref|Own)Ptr` to nullptr - Fix unsigned int& => unsigned long& conversion
2021-07-11AK: Bring back FixedArray<T>Andreas Kling
Let's bring this class back, but without the confusing resize() API. A FixedArray<T> is simply a fixed-size array of T. The size is provided at run-time, unlike Array<T> where the size is provided at compile-time.
2021-07-05JsonParser: Bring parser more to specstelar7
2021-07-04Tests: Add test for String::roman_number_from()Tobias Christiansen
2021-07-04Everywhere: Prefer using "..."sv over StringView { "..." }Gunnar Beutner
2021-07-04Tests: Add tests for `Optional`'s conditionally trivial functionsDaniel Bertalan
2021-07-04AK: Destroy original value when assigning to VariantDaniel Bertalan
2021-07-04Tests: Add test for supported operation type traitsDaniel Bertalan
2021-07-02Tests: Add test for String::find with empty needleMax Wipfli
This adds a test case for String::find and String::find_all with empty needles. The expected behavior is in line with what the C++ standard library (and other languages standard libraries) expect.
2021-07-02AK: Implement String::find_any_of() and StringView::find_any_of()Max Wipfli
This implements StringUtils::find_any_of() and uses it in String::find_any_of() and StringView::find_any_of(). All uses of find_{first,last}_of have been replaced with find_any_of(), find() or find_last(). find_{first,last}_of have subsequently been removed.
2021-07-02AK+Everywhere: Remove StringView::find_{first,last}_of(char) methodsMax Wipfli
This removes StringView::find_first_of(char) and find_last_of(char) and replaces all its usages with find and find_last respectively. This is because those two methods are functionally equivalent. find_{first,last}_of should only be used if searching for multiple different characters, which is never the case with the char argument. This also adds the [[nodiscard]] to the remaining find_{first,last}_of methods.
2021-06-30AK+Everywhere: Remove "null state" of LexicalPathMax Wipfli
This removes the default constructor of LexicalPath, and subsequently modifies all its users to accommodate the change.
2021-06-30AK: Make LexicalPath immutableMax Wipfli
This replaces the current LexicalPath::append() API with a new method that returns a new LexicalPath object and doesn't touch the this-object. With this, LexicalPath is now immutable. It also adds a LexicalPath::parent() method and the relevant test cases.
2021-06-30Tests: Rewrite tests for LexicalPathMax Wipfli
2021-06-30AK: Remove the LexicalPath::is_valid() APIMax Wipfli
Since this is always set to true on the non-default constructor and subsequently never modified, it is somewhat pointless. Furthermore, there are arguably no invalid relative paths.
2021-06-28AK: Add and use the RemoveCVReference<T> type traitAli Mohammad Pur
2021-06-27AK: Make the constexpr StringView methods actually constexprAli Mohammad Pur
Also add some tests to ensure that they _remain_ constexpr. In general, any runtime assertions, weirdo C casts, pointer aliasing, and such shenanigans should be gated behind the (helpfully newly added) AK::is_constant_evaluated() function when the intention is to write constexpr-capable code. a.k.a. deliver promises of constexpr-ness :P
2021-06-26AK: Undo bogus Variant::downcast() renameAndreas Kling
I accidentally renamed these to verify_cast() when doing the global AK::downcast() rename.
2021-06-24AK: Rename downcast<T> => verify_cast<T>Andreas Kling
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-06-24Tests: Reduce runtime of TestCharacterTypesMax Wipfli
This declares all test cases which compare function outputs over the entire Unicode range as `BENCHMARK_CASE`, to avoid them being run by CI. This reduces runtime of TestCharacterTypes (without benchmarks) by about one third.
2021-06-19AK: Add support for keeping trailing zeros in fixed precision floatsIdan Horowitz
This uses the same syntax as zero padding integers: String::formatted("{:0.5}", 1.234) => "1.23400"
2021-06-17AK: Add some tests for hexdump formattingAli Mohammad Pur
2021-06-16AK+Tests: Add IntrusiveList<T,...>::insert_before(..) methodBrian Gianforcaro
The insert_before method on AK::InlineLinkedList is used, so in order to achieve feature parity, we need to implement it for AK::IntrusiveList as well.
2021-06-15AK: Add support for removing SinglyLinkedList nodes during iterationIdan Horowitz
This commit also fixes the now-broken usage of SinglyLinkedList::remove in the Piano application.
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-11AK+LibX86: Generalize u128/256 to AK::UFixedBigIntHendiadyoin1
Doing these as custom classes might be faster, especially when writing them in SSE, but this would cause a lot of Code duplication and due to the nature of constexprs and the intelligence of the compiler they might be using SSE/MMX either way
2021-06-08AK: Make Vector capable of holding reference typesAli Mohammad Pur
This commit makes it possible to instantiate `Vector<T&>` and use it to store references to `T` in a vector. All non-pointer observers are made to return the reference, and the pointer observers simply yield the underlying pointer. Note that the 'find_*' methods act on the values and not the pointers that are stored in the vector. This commit also makes errors in various vector methods much more readable by directly using requires-clauses on them. And finally, it should be noted that Vector cannot hold temporaries :^)
2021-06-07AK: Add IntrusiveList::size_slow() to match InlineLinkedListBrian Gianforcaro
The functionality is needed to replace InlineLinkedList with IntrusiveList in the Kernel Process class.
2021-06-05AK: Do not trim away non-ASCII bytes when parsing URLMax Wipfli
Because non-ASCII code points have negative byte values, trimming away control characters requires checking for negative bytes values. This also adds a test case with a URL containing non-ASCII code points.
2021-06-04AK: Don’t drop lines between \r and \n in StringView::lines() (#7662)R Smith
StringView::lines() supports line-separators β€œ\n”, β€œ\r”, and β€œ\r\n”. The method will drop an entire line if it is surrounded by β€œ\r” and β€œ\n” separators on the left and right sides respectively.
2021-06-03AK: Do not VERIFY on invalid code point bytes in UTF8ViewDexesTTP
The previous behavior was to always VERIFY that the UTF-8 bytes were valid when iterating over the code points of an UTF8View. This change makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER' code point when encountering invalid bytes, and keep iterating the view after skipping one byte. Leaving the decision to the consumer would break symmetry with the UTF32View API, which would in turn require heavy refactoring and/or code duplication in generic code such as the one found in Gfx::Painter and the Shell. To make it easier for the consumers to detect the original bytes, we provide a new method on the iterator that returns a Span over the data that has been decoded. This method is immediately used in the TextNode::compute_text_for_rendering method, which previously did this in a ad-hoc waay. This also add tests for the new behavior in TestUtf8.cpp, as well as reinforcements to the existing tests to check if the underlying bytes match up with their expected values.
2021-06-03Tests: Add tests for most functions in AK/CharacterType.hMax Wipfli
2021-06-03Tests: Add test coverage for AK::IntrusiveList reverse iterator supportBrian Gianforcaro
2021-06-01AK+Everywhere: Fix compiletime format parsing of replacement fieldsAli Mohammad Pur