summaryrefslogtreecommitdiff
path: root/Tests/AK
AgeCommit message (Collapse)Author
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
2021-06-01AK: Strip leading/trailing C0-control-or-space in URLs correctlyAndreas Kling
We have to stop scanning once we hit a non-strippable character. Add some tests to cover this.
2021-06-01AK: Enable direct comparsion of Optional<T> and TMax Wipfli
This patch introduces a new operator== to compare an Optional to its contained type directly. If the Optional does not contain a value, the comparison will always return false. This also adds a test case for the new behavior as well as comparison between Optional objects themselves.
2021-06-01AK: Rename Utf8CodepointIterator => Utf8CodePointIteratorAndreas Kling
2021-06-01Tests: Add more tests for AK::URLMax Wipfli
This adds more tests for AK::URL. Furthermore, this also changes some tests to conform to what the reworked URL class does (and the URL specification mostly expects).
2021-06-01AK: Implement Utf8CodepointIterator::peek(size_t)Max Wipfli
This adds a peek method for Utf8CodepointIterator, which enables it to be used in some parsing cases where peeking is necessary. peek(0) is equivalent to operator*, expect that peek() does not contain any assertions and will just return an empty Optional<u32>. This also implements a test case for iterating UTF-8.
2021-05-31AK: Handle LEB128 encoded values that are too large for the result typeAndrew Kaster
Previously, we would go crazy and shift things way out of bounds. Add tests to verify that the decoding algorithm is safe around the limits of the result type.
2021-05-31AK: Add tests for LEB128 decoderAndrew Kaster
2021-05-30AK+Userland: Use akaster@serenityos.org for my copyright headersAndrew Kaster
2021-05-30AK: Make HashTable::operator=(HashTable&&) clear the moved-from tableAndreas Kling
This is consistent with how other AK containers behave when moved from.
2021-05-27Tests: Add tests for LexicalPath dirname handlingTim Schumacher
2021-05-26AK: Implement AK::StackJesse Buhagiar
2021-05-24AK+Everywhere: Consolidate String::index_of() and String::find()Andreas Kling
We had two functions for doing mostly the same thing. Combine both of them into String::find() and use that everywhere. Also add some tests to cover basic behavior.
2021-05-22AK: Fix Variant construction from lvalue referencesAli Mohammad Pur
Fixes #7371 and appends its test cases.
2021-05-20AK: Added contains_in_range to Vectorr-paiva
Vector::contains_in_range() allows the search of an element in a given range on a vector object. Also added testcases for the new Vector method.
2021-05-19Tests: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-19AK: Add String::find_all() and String::count()Maciej Zygmanowski
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
2021-05-19AK: Allow AK::Variant::visit to return a valueTimothy Flynn
This changes Variant::visit() to forward the value returned by the selected visitor invocation. By perfectly forwarding the returned value, this allows for the visitor to return by value or reference. Note that all provided visitors must return the same type - the compiler will otherwise fail with the message: "inconsistent deduction for auto return type".
2021-05-18AK: Make LexicalPath handle relative paths correctlyGunnar Beutner
Previously LexicalPath would consider "." and ".." as equivalent to "/". This is not true though.
2021-05-16AK: Don't read past the end in BitmapView::count_in_range()Andrew Kaster
The current code is factored such that reads to the entirety of the last byte should be dropped. This was relying on the fact that last would be one past the end in that case. Instead of actually reading that byte when it's completely out of bounds of the bitmask, just skip reads that would be invalid. Add more tests to make sure that the behavior is correct for byte aligned reads of byte aligned bitmaps.
2021-05-14Tests: Mark use-after-scope NeverDestroyed test NO_SANITIZE_ADDRESSAndrew Kaster
The should_not_destroy test case intentionally performs an invalid stack access on a NeverDestroyed to confirm that the destructor for the held type was not called.
2021-05-14Tests: Fix use-after-free in TestRefPtr.self_observersAndrew Kaster
We can't unref an object to destruction while there's still a live RefPtr to the object, otherwise the RefPtr destructor will try to destroy it again, accessing the refcount of a destroyed object (before realizing that oops! the object is already dead)
2021-05-13AK: Introduce adopt_ref_if_nonnull(..) to aid in Kernel OOM hardeningBrian Gianforcaro
Unfortunately adopt_ref requires a reference, which obviously does not work well with when attempting to harden against allocation failure. The adopt_ref_if_nonnull() variant will allow you to avoid using bare pointers, while still allowing you to handle allocation failure.
2021-05-11AK: Add a Tuple implementationAli Mohammad Pur
Please don't use this outside of metaprogramming needs, *please*.
2021-05-11AK/Variant: Deduplicate the contained typesAli Mohammad Pur
This allows the construction of `Variant<int, int, int>`. While this might not seem useful, it is very useful for making variants that contain a series of member function pointers, which I plan to use in LibGL for glGenLists() and co.
2021-05-07AK: Implement Span::starts_with()Valtteri Koskivuori
Useful for checking for contents at the start of a span.
2021-05-07Tests: Add tests for Checked<T>::div() overflowAli Mohammad Pur
2021-05-06Tests: Move AK tests to Tests/AKBrian Gianforcaro