summaryrefslogtreecommitdiff
path: root/AK/Tests
AgeCommit message (Collapse)Author
2021-05-06Tests: Move AK tests to Tests/AKBrian Gianforcaro
2021-05-05AK: Add a Variant<Ts...> implementationAli Mohammad Pur
Also adds an AK::Empty struct, because 'empty' variants are useful, but this implementation leaves that to the user (i.e. a variant cannot actually be empty, but it can contain an instance of Empty - i.e. a byte). Note that this is more of a constrained Any type, but they basically do the same things anyway :^)
2021-04-29Everywhere: "file name" => "filename"Andreas Kling
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
We had some inconsistencies before: - Sometimes "The", sometimes "the" - Sometimes trailing ".", sometimes no trailing "." I picked the most common one (lowecase "the", trailing ".") and applied it to all copyright headers. By using the exact same string everywhere we can ensure nothing gets missed during a global search (and replace), and that these inconsistencies are not spread any further (as copyright headers are commonly copied to new files).
2021-04-25Everywhere: Remove empty line after function body opening curly braceLinus Groh
2021-04-25Tests: Remove 4chan catalog JSON from treesin-ack
According to kling, it was "an early stress test for the JSON decoder" and can be removed now.
2021-04-25AK+Userland: Move AK/TestSuite.h into LibTest and rework Tests' CMakeAndrew Kaster
As many macros as possible are moved to Macros.h, while the macros to create a test case are moved to TestCase.h. TestCase is now the only user-facing header for creating a test case. TestSuite and its helpers have moved into a .cpp file. Instead of requiring a TEST_MAIN macro to be instantiated into the test file, a TestMain.cpp file is provided instead that will be linked against each test. This has the side effect that, if we wanted to have test cases split across multiple files, it's as simple as adding them all to the same executable. The test main should be portable to kernel mode as well, so if there's a set of tests that should be run in self-test mode in kernel space, we can accomodate that. A new serenity_test CMake function streamlines adding a new test with arguments for the test source file, subdirectory under /usr/Tests to install the test application and an optional list of libraries to link against the test application. To accomodate future test where the provided TestMain.cpp is not suitable (e.g. test-js), a CUSTOM_MAIN parameter can be passed to the function to not link against the boilerplate main function.
2021-04-24AK: Add SourceLocation supportBrian Gianforcaro
C++20 added std::source_location, which lets you capture the callers __FILE__ / __LINE__ / __FUNCTION__ etc as a default argument to functions. See: https://en.cppreference.com/w/cpp/utility/source_location During a bug investigation @ADKaster suggested we could use this to make the LOCK_DEBUG feature of the kernel more user friendly and allow it to automatically instrument all call sites. We then implemented / tested it over discord. :^) Co-Authored-by: Andrew Kaster <andrewdkaster@gmail.com>
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22AK+Userland: Use idan.horowitz@serenityos.org for my copyright headersIdan Horowitz
2021-04-22Everywhere: Use bgianf@serenityos.org for my copyright attributionBrian Gianforcaro
2021-04-22AK/GenericLexer: constexpr where possibleLenny Maiorani
Problem: - Much of the `GenericLexer` can be `constexpr`, but is not. Solution: - Make it `constexpr` and de-duplicate code. - Extend some of `StringView` with `constexpr` to support. - Add tests to ensure `constexpr` behavior. Note: - Construction of `StringView` from pointer and length is not `constexpr`-compatible at the moment because the VERIFY cannot be, yet.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22AK: Reenable the IntrusiveList<...NonnullRefPtr, ...> testsAli Mohammad Pur
2021-04-21AK: Add unit tests to verify AK::InstrusiveList<T> holding RefPtr<T>Brian Gianforcaro
Validate that the refcounting works as expected, and continues to work.
2021-04-21AK: Add some initial unit tests for AK::IntrusiveListBrian Gianforcaro
2021-04-19AK/Tests: Install test fixtures required for TestJSONLeon Albrecht
2021-04-18AK/Hex: Cleanup implementationLenny Maiorani
Problem: - Post-increment of loop index. - `const` variables are not marked `const`. - Incorrect type for loop index. Solution: - Pre-increment loop index. - Mark all possible variables `const`. - Corret type for loop index.
2021-04-18AK/Hex: Decode hex digit in constexpr contextLenny Maiorani
Problem: - Hex digit decoding is not `constexpr`, but can be. Solution: - Move the body of the function to the header and decorate with `constexpr`. - Provide tests for run-time and compile-time evaluation.
2021-04-18AK/Complex: C++20-compatible comparison operatorsLenny Maiorani
Problem: - Clang correctly reports non-`const` member function comparison operators as ambiguous. Solution: - Make them `const`.
2021-04-16AK: Fix incorrect formatter signing of numbers between -1.0 and 0.0Matthew Olsson
Floating point numbers are casted to i64 and passed to the integer formatting logic, and the floating point portion of the number is handled separately. However, casting to i64 when the number is between -1.0 and 0.0 produces 0, so the sign would be lost. This commit fixes that by using put_u64 instead, which allows us to manually provide the is_negative flag.
2021-04-12AK: Fix StringView::find_last_of for one-character viewsTimothy Flynn
The find_last_of implementations were breaking out of the search loop too early for single-character string views. This caused a crash in CookieJar setting a cookie on google.com - CookieJar::default_path knew there was at least one "/" in a string view, but find_last_of returned nullopt, so dereferencing the optional caused a crash. Fixes #6273
2021-04-12AK: Add a predicate variant of StringView::split_viewTimothy Flynn
2021-04-12AK: Implement IntrusiveRedBlackTree containerIdan Horowitz
This container is similar to the RedBlackTree container, but instead of transparently allocating tree nodes on insertion and freeing on removal this container piggybacks on intrusive node fields in the stored class
2021-04-12AK: Implement RedBlackTree containerIdan Horowitz
This container is based on a balanced binary search tree, and as such allows for O(logn) worst-case insertion, removal, and search, as well as O(n) sorted iteration.
2021-04-11AK: Update LexicalPath::relative_path to work for '/' prefixTim Waterhouse
If the prefix path is just a slash the LexicalPath was removing too many characters. Now only remove an extra character if the prefix is not just the root path.
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
2021-04-08Format: Strip trailing zeroes from floating point valuesJelle Raaijmakers
This is a pretty naive implementation that works well. The precision parameter is interpreted as "maximum precision" instead of "minimum precision", which in my opinion is the most useful interpretation.
2021-04-08Tests: Merge duplicate TestFormat test into AK directoryJelle Raaijmakers
2021-04-02AK: Add tests for HashTablethislooksfun
2021-03-28AK: Add IsSigned conterpart to IsUnsigned.Michel Hermier
2021-03-28AK: Remove IsSigned<char> test as it is platform/compiler dependant.Michel Hermier
2021-03-27AK: Add complex number libraryCesar Torres
Useful for diverse algorithms. Also added some tests for it.
2021-03-23AK: Implement bit_castOleg Sikorskiy
2021-03-17AK: Implement terabytes, petabytes, exabytesJean-Baptiste Boric
2021-03-17Everywhere: Remove pessimizing and redundant move()Andreas Kling
2021-03-17AK: Tests: TestURL: Add port_int_overflow_wrap testBrendan Coles
2021-03-13AK: Implement minimum BinaryHeapIdan Horowitz
This enables efficient implementations of priority queues, and will also be used in LibCompress for efficient huffman tree generation.
2021-03-13AK: Fix some overflows/underflows that weren't properly handledBen Wiederhake
Based on #5699. Closes #5699.
2021-03-08AK: Add AK_ENUM_BITWISE_OPERATORS(..) to enable type-safe enum bitwise ↵Brian Gianforcaro
operations This change introduces `AK_ENUM_BITWISE_OPERATORS(..)` which when enabled for an enum, will automatically declare all the necessary bitwise operators for that enum. This allows bit masks enums to be used as first class, type safe, citizens.
2021-03-08AK: Take advantage of constexpr in Time and add time conversion methodsTom
By making the Time constructor constexpr we can optimize creating a Time instance from hardcoded values. Also add more functions to convert between Time and various time units.
2021-03-07AK+Tests: Also test Checked<> with unsignedBen Wiederhake
As expected, Checked<unsigned> works as intended. However, we didn't have a test for that, so I added one. See also 90c070cb1d90d77ba461017e609b9f8ee6326de1.
2021-03-05AK: Implement IsEnum<T> and UnderlyingType<T> type traitsBrian Gianforcaro
I needed these meta-programming type traits while working on something else. Add basic support for these two type traits as well as some tests.
2021-03-02AK: Make Time more usableBen Wiederhake
2021-03-02AK: Implement C++ 'Time' type for easier time-calculationsBen Wiederhake
This adds a bunch of code in the hope that other, wrong code can be deleted. Related to #5315.
2021-03-02AK+Tests: Test Checked for main functionalityBen Wiederhake
2021-02-28Meta: Build AK and LibRegex tests in Lagom and for SerenityAndrew Kaster
These tests were never built for the serenity target. Move their Lagom build steps to the Lagom CMakeLists.txt, and add serenity build steps for them. Also, fix the build errors when building them with the serenity cross-compiler :^)
2021-02-27AK: Use Array iterator instead of indexing outside Array boundsAndreas Kling
2021-02-26Everywhere: Remove a bunch of redundant 'AK::' namespace prefixesLinus Groh
This is basically just for consistency, it's quite strange to see multiple AK container types next to each other, some with and some without the namespace prefix - we're 'using AK::Foo;' a lot and should leverage that. :^)
2021-02-24AK: Add support for AK::StringView literals with operator""svBrian Gianforcaro
A new operator, operator""sv was added as of C++17 to support string_view literals. This allows string_views to be constructed from string literals and with no runtime cost to find the string length. See: https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv This change implements that functionality in AK::StringView. We do have to suppress some warnings about implementing reserved operators as we are essentially implementing STL functions in AK as we have no STL :).