Commit graph

9 commits

Author SHA1 Message Date
Brian Gianforcaro 67322b0702 Tests: Move AK tests to Tests/AK 2021-05-06 17:54:28 +02:00
Andrew Kaster 35c0a6c54d AK+Userland: Move AK/TestSuite.h into LibTest and rework Tests' CMake
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-25 09:36:49 +02:00
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00
Andreas Kling 1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Lenny Maiorani 2983215fb1 Base64: Pre-allocate size of input and output
Problem:
- Output of decode and encode grow as the decode and encode
  happen. This is inefficient because a large size will require many
  reallocations.
- `const` qualifiers are missing on variables which are not intended
  to change.

Solution:
- Since the size of the decoded or encoded message is known prior to
  starting, calculate the size and set the output to that size
  immediately. All appends will not incur the reallocation overhead.
- Add `const` qualifiers to show intent.
2020-10-13 23:59:46 +02:00
asynts abe925e4b0 AK: Change the signature of AK::encode_base64() to use Span. 2020-07-27 19:58:09 +02:00
Nico Weber 5ba8aba197 AK: Make encode_base64 take a ByteBuffer and return a String
That makes the interface symmetric with decode_base64 and it's
what all current callers want (except for one, which is buggy).
2020-07-22 19:22:00 +02:00
Tom Lebreux e14c8b2707 AK: Add tests for Base64 decoder 2020-06-18 23:21:41 +02:00
Tom Lebreux 79529ffd47 AK: Add a simple and inefficient Base64 encoder
The test cases are taken from RFC 4648.
2020-06-18 23:21:41 +02:00