summaryrefslogtreecommitdiff
path: root/Tests/AK
AgeCommit message (Collapse)Author
2023-03-15AK: Clear OrderedHashTable previous/next pointers on removalJelle Raaijmakers
With Clang, the previous/next pointers in buckets of an `OrderedHashTable` are not cleared when a bucket is being shifted up as a result of a removed bucket. As a result, an unfortunate pointer mixup could lead to an infinite loop in the `HashTable` iterator, which was exposed in `HashMap::keys()`. Co-authored-by: Luke Wilde <lukew@serenityos.org>
2023-03-14AK: Rename CaseInsensitiveStringViewTraits to reflect intentgustrb
Now it is called `CaseInsensitiveASCIIStringViewTraits`, so we can be more specific about what data structure does it operate onto. ;)
2023-03-13Everywhere: Remove unintentional partial stream reads and writesTim Schumacher
2023-03-13AK: Rename Stream::write_entire_buffer to Stream::write_until_depletedTim Schumacher
No functional changes.
2023-03-13AK: Rename Stream::{read,write} to Stream::{read_some,write_some}Tim Schumacher
Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs.
2023-03-08AK+LibUnicode: Implement String::equals_ignoring_case without allocatingTimothy Flynn
We currently fully casefold the left- and right-hand sides to compare two strings with case-insensitivity. Now, we casefold one code point at a time, storing the result in a view for comparison, until we exhaust both strings.
2023-03-08AK: Make String::contains(code_point) handle non-ASCIITimothy Flynn
We currently only accept a char, instead of a full code point.
2023-03-08AK: Make String::{starts,ends}_with(code_point) handle non-ASCIITimothy Flynn
We currently pass the code point to StringView::{starts,ends}_with, which actually accepts a single char, thus cannot handle non-ASCII code points.
2023-03-06Everywhere: Remove NonnullOwnPtr.h includesAndreas Kling
2023-03-06Everywhere: Stop using NonnullOwnPtrVectorAndreas Kling
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-04AK: Implement Knuth's algorithm D for dividing UFixedBigInt'sDan Klishch
2023-03-04AK: Delete unused and untested sqrt, pow and pow_mod from UFixedBigIntDan Klishch
2023-03-03AK: Ensure short String instances are valid UTF-8Timothy Flynn
We are currently only validating long strings.
2023-03-03AK: Invalidate overlong UTF-8 code point encodingsTimothy Flynn
For example, the code point U+002F could be encoded as UTF-8 with the bytes 0x80 0xAF. This trick has historically been used to bypass security checks.
2023-03-03AK: Make FixedPoint(FloatingPoint) ctor round instead of truncatingNico Weber
This is needed to have code for creating an in-memory sRGB profile using the (floating-ppoint) numbers from the sRGB spec and having the fixed-point values in the profile match what they are in other software (such as GIMP). It has the side effect of making the FixedPoint ctor no longer constexpr (which seems fine; nothing was currently relying on that). Some of FixedPoint's member functions don't round yet, which requires tweaking a test.
2023-02-28AK+Everywhere: Make GenericLexer::ignore_until() stop before the valueSam Atkins
`consume_until(foo)` stops before foo, and so does `ignore_until(Predicate)`, so let's make the other `ignore_until()` overloads consistent with that so they're less confusing.
2023-02-26AK: Fix DeprecatedString::bijective_base_from for large numbersTim Ledbetter
The output of the DeprecatedString::bijective_base_from() is now correct for numbers larger than base^2. This makes column names display correctly in Spreadsheet.
2023-02-25Everywhere: Use _{short_,}string to create Strings from literalsLinus Groh
2023-02-21AK: Add `take_first` to HashTable and rename `pop` to `take_last`Hediadyoin1
This naming scheme matches Vector. This also changes `take_last` to move the value it takes, and delete by known pointer, avoiding a full lookup and potential copies.
2023-02-21AK: Add String::from_stream methodAndrew Kaster
The caller is responsible for determining how long the string is that they want to read.
2023-02-18AK: Fix printing of negative FixedPoint valuesNico Weber
Fixes #17514 by comparing to 0 before truncating the fractional part.
2023-02-18AK: Fix 64-bit alignment issue in shared-superstring substringsAndreas Kling
Thanks to Timothy Flynn for the test! Fixes #17141
2023-02-17AK: Remove unused `rehash_for_collision`Jelle Raaijmakers
2023-02-17AK: Reimplement `HashTable` with smart linear probingJelle Raaijmakers
Instead of rehashing on collisions, we use Robin Hood hashing: a simple linear probe where we keep track of the distance between the bucket and its ideal position. On insertion, we allow a new bucket to "steal" the position of "rich" buckets (those near their ideal position) and move them further down. On removal, we shift buckets back up into the freed slot, decrementing their distance while doing so. This behavior automatically optimizes the number of required probes for any value, and removes the need for periodic rehashing (except when expanding the capacity).
2023-02-18AK: Add `AK::SIMD::exp_approximate`Jelle Raaijmakers
This approximation tries to generate values within 0.1% of their actual expected value. Microbenchmarks indicate that this iterative SIMD version can be up to 60x faster than `AK::SIMD::exp`.
2023-02-15AK+Tests+LibWeb: Make `URL::complete_url()` take a StringViewSam Atkins
All it does is pass this to `URLParser::parse()` which takes a StringView, so we might as well take one here too.
2023-02-15LibUnicode: Fix typos causing text segmentation on mid-word punctuationTimothy Flynn
For example the words "can't" and "32.3" should not have boundaries detected on the "'" and "." code points, respectively. The String test cases fixed here are because "b'ar" is now considered one word.
2023-02-13Everywhere: Remove the `AK::` qualifier from Stream usagesTim Schumacher
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-11Tests: Add a few tests to verify vectors are using inline storageMacDue
2023-02-10AK: Allow Vector<ByteBuffer>::contains_slow to accept (Readonly)BytesLuke Wilde
This is done by providing Traits<ByteBuffer>::equals functions for (Readonly)Bytes, as the base GenericTraits<T>::equals is unable to convert the ByteBuffer to (Readonly)Bytes to then use Span::operator== This allows us to check if a Vector<ByteBuffer> contains a (Readonly)Bytes without having to making a copy of it into a ByteBuffer first. The initial use of this is in LibWeb with CORS-preflight, where we check the split contents of the Access-Control headers with Fetch::Infrastructure::Request::method() and static StringViews such as "*"sv.bytes().
2023-02-08AK: Remove the deprecated Stream implementation :^)Tim Schumacher
2023-02-08Everywhere: Use ReadonlySpan<T> instead of Span<T const>MacDue
2023-02-08AK: Remove the fallible constructor from `FixedMemoryStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `LittleEndianOutputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallbile constructor from `BigEndianOutputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `LittleEndianInputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `BigEndianInputBitStream`Tim Schumacher
2023-02-04AK: Make LEB128 decoding work with `read_value`Tim Schumacher
2023-02-04AK: Port `LEB128` to the new `AK::Stream`Tim Schumacher
2023-02-03AK: Add thresholds to `quickselect_inline` and `Statistics::Median`Staubfinger
I did a bit of Profiling and made the quickselect and median algorithms use the best of option for the respective input size.
2023-02-03AK: Testing for `AK::quickselect_inline`Staubfinger
The testing code found here is mainly derived from the Tests for `AK::quick_sort`.
2023-02-02AK: Define HashMap::take to find and remove a value from the mapTimothy Flynn
2023-02-02AK: Ensure string types are actually considered hash-compatibleTimothy Flynn
The AnyString concept is currently broken because it checks whether a StringView is constructible from a type T. The StringView constructors, however, only accept constant rvalue references - i.e. `T const&`. This also adds a test to ensure this continues to work.
2023-01-31AK: Fix all quadratic-time append-loops over ByteBufferBen Wiederhake
2023-01-29AK: Move memory streams from `LibCore`Tim Schumacher
2023-01-29AK: Move bit streams from `LibCore`Tim Schumacher
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-28AK: Remove `try_` prefix from FixedArray creation functionsLinus Groh
2023-01-28AK: Add String::trimTimothy Flynn