summaryrefslogtreecommitdiff
path: root/AK/TestSuite.h
AgeCommit message (Collapse)Author
2021-04-18Tests: Fix test-math expected valuesMarco Biscaro
Some of the expected values in test-math were wrong, which caused some tests to fail. The updated values were generated by Python's math library, and rounded to 6 decimals places: >>> import math >>> round(math.exp(20.99), 6) 1305693298.670892 Examples of failure outputs: FAIL: ../Userland/Tests/LibM/test-math.cpp:98: EXPECT_APPROXIMATE(exp(v.x), v.exp) failed with lhs=1305693298.670892, rhs=1304956710.432034, (lhs-rhs)=736588.238857 FAIL: ../Userland/Tests/LibM/test-math.cpp:99: EXPECT_APPROXIMATE(sinh(v.x), v.sinh) failed with lhs=652846649.335446, rhs=652478355.216017, (lhs-rhs)=368294.119428 FAIL: ../Userland/Tests/LibM/test-math.cpp:100: EXPECT_APPROXIMATE(cosh(v.x), v.cosh) failed with lhs=652846649.335446, rhs=652478355.216017, (lhs-rhs)=368294.119429
2021-04-16Everywhere: Add `-Wdouble-promotion` warningNicholas-Baron
This warning informs of float-to-double conversions. The best solution seems to be to do math *either* in 32-bit *or* in 64-bit, and only to cross over when absolutely necessary.
2021-03-03AK+LibM: Rename EXPECT_CLOSE to EXPECT_APPROXIMATEBen Wiederhake
2021-03-03AK+LibM: Make EXPECT_CLOSE more useful during debuggingBen Wiederhake
2021-03-01AK/Lagom: Modify TestSuite to return how many tests failed from mainAndrew Kaster
This allows us to remove the FAIL_REGEX logic from the CTest invocation of AK and LibRegex tests, as they will return a non-zero exit code on failure :^). Also means that running a failing TestSuite-enabled test with the run-test-and-shutdown script will actually print that the test failed.
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-23Everywhere: Remove unused RELEASE_ASSERT macroAndreas Kling
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-23AK+Userland: Extend the compiletime format string check to other functionsAnotherTest
Thanks to @trflynn89 for the neat implicit consteval ctor trick! This allows us to basically slap `CheckedFormatString` on any formatting function, and have its format argument checked at compiletime. Note that there is a validator bug where it doesn't parse inner replaced fields like `{:~>{}}` correctly (what should be 'left align with next argument as size' is parsed as `{:~>{` following a literal closing brace), so the compiletime checks are disabled on these temporarily by forcing them to be StringViews. This commit also removes the now unused `AK::StringLiteral` type (which was introduced for use with NTTP strings).
2021-02-23AK: Untangle TestSuite assertions a bitAnotherTest
2020-10-14AK: Don't forward declare abort.asynts
There is no portable way to forward declare abort because the libc implementations disagree on the signature. Originally, I added a __portable_abort function with a "portable" signature which just called abort. But I really don't like it and just including <stdlib.h> is simpler. Note that the headers we include in <AK/TestSuite.h> are no longer commutative now, we have to include <stdlib.h> before anything else.
2020-10-08AK: Use new format functions.asynts
2020-10-04AK: Don't add newline for outf/dbgf/warnf.asynts
In the future all (normal) output should be written by any of the following functions: out (currently called new_out) outln dbg (currently called new_dbg) dbgln warn (currently called new_warn) warnln However, there are still a ton of uses of the old out/warn/dbg in the code base so the new functions are called new_out/new_warn/new_dbg. I am going to rename them as soon as all the other usages are gone (this might take a while.) I also added raw_out/raw_dbg/raw_warn which don't do any escaping, this should be useful if no formatting is required and if the input contains tons of curly braces. (I am not entirely sure if this function will stay, but I am adding it for now.)
2020-10-03Everywhere: Fix more typosLinus Groh
2020-09-28AK+TestSuite: Don't assume that the test passed in output.asynts
The problem with our test suite is that it can't detect if a test failed. When a test fails we simply write 'FAIL ...' to stderr and move on. Previously, the test suite would list all tests as passing regardless how many assertions failed. In the future it might be smart to implement this properly but test suites for C++ are always hard to do nicely. (Because C++ execution isn't meant to be embedded.)
2020-08-25AK: TestSuite: Define assert macros with do { } while(0). (#3292)Paul Scharnofske
Consider the following scenario: if(condition) FOO(); else bar(); Suppose FOO is defined as follows: #define FOO() { bar(); baz(); } Then it expands to the following: if(condition) // Syntax error, we are not allowed to put a semicolon at the end. { bar(); baz(); }; else bar(); If we define FOO as follows: #define FOO() do { bar(); baz(); } while(false) Then it expands to the following: if(condition) do { bar(); baz(); } while(false); else bar(); Which is correct.
2020-08-23AK: Print RHS and LHS in EXPECT_EQ if we canBen Wiederhake
This makes error messages more useful during debugging. Old: START Running test compare_views FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed New: START Running test compare_views FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed: LHS="foo", RHS="foobar"
2020-08-22AK: TestSuite: Terminate when ASSERT_NOT_REACHED is called.asynts
Previously, it would just print something with 'FAIL' to stderr which would be picked up by CTest. However, some code assumes that ASSERT_NOT_REACHED() doesn't return, for example: bool foo(int value) { switch(value) { case 0: return true; case 1: return false; default: ASSERT_NOT_REACHED(); } // warning: control reaches end of non-void function }
2020-08-22AK: Make some tweaks in TestSuite.h.asynts
2020-08-22AK: Remove <chrono> requirement from TestSuite.h.asynts
2020-08-22AK: Remove exceptions from TestSuite.h.asynts
Serenity is build with -fno-exceptions, this is an effort to make TestSuite.h useable in the userland.
2020-08-10AK: TestSuite's main should return 0Ben Wiederhake
2020-05-30AK+LibC: Add TODO() as an alternative to ASSERT_NOT_REACHED()Andreas Kling
I've been using this in the new HTML parser and it makes it much easier to understand the state of unfinished code branches. TODO() is for places where it's okay to end up but we need to implement something there. ASSERT_NOT_REACHED() is for places where it's not okay to end up, and something has gone wrong.
2020-03-02AK: Move the wildcard-matching implementation to StringUtilshowar6hill
Provide wrappers in the String and StringView classes, and add some tests.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-11-06AK: Get rid of TStyle (output styling helper for LogStream)Andreas Kling
This didn't end up getting used, so let's get rid of it.
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-02TestSuite: Hijack the ASSERT macros during unit tests.Andreas Kling
Instead of aborting the program when we hit an assertion, just print a message and keep going. This allows us to write tests that provoke assertions on purpose.
2019-08-01TestSuite: Actually print failed comparions.. :^)Andreas Kling
2019-07-21TestSuite: Don't leak the suite instanceRobin Burchell
Makes checking for leaks more straightforward
2019-07-21TestSuite: instance() -> the(), and return a referenceRobin Burchell
To be more consistent with the rest of the codebase
2019-07-21TestSuite: Make tests actually run (oops!)Andreas Kling
We were not actually running any of the unit tests, only getting a pointer to them. Thankfully they all pass, even after we start running them. :^)
2019-07-16AK: Add a new TestSuite.h from my own work, adapted to match the existing ↵Robin Burchell
one a bit This gives a few new features: * benchmarks * the ability to run individual testcases easily * timing of tests