mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Fix all the warnings in the AK tests
This commit is contained in:
parent
75a6b27f73
commit
b866582d98
Notes:
sideshowbarker
2024-07-19 08:52:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b866582d987
8 changed files with 68 additions and 67 deletions
|
@ -24,31 +24,32 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/CircularDeque.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/TestSuite.h>
|
||||
|
||||
TEST_CASE(enqueue_begin)
|
||||
{
|
||||
CircularDeque<int, 3> ints;
|
||||
|
||||
ints.enqueue_begin(0);
|
||||
EXPECT_EQ(ints.size(), 1);
|
||||
EXPECT_EQ(ints.size(), 1u);
|
||||
EXPECT_EQ(ints.first(), 0);
|
||||
|
||||
ints.enqueue_begin(1);
|
||||
EXPECT_EQ(ints.size(), 2);
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
EXPECT_EQ(ints.first(), 1);
|
||||
EXPECT_EQ(ints.last(), 0);
|
||||
|
||||
ints.enqueue_begin(2);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints.first(), 2);
|
||||
EXPECT_EQ(ints.last(), 0);
|
||||
|
||||
ints.enqueue_begin(3);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints.first(), 3);
|
||||
EXPECT_EQ(ints.at(1), 2);
|
||||
EXPECT_EQ(ints.last(), 1);
|
||||
|
@ -69,13 +70,13 @@ TEST_CASE(deque_end)
|
|||
ints.enqueue(0);
|
||||
ints.enqueue(1);
|
||||
ints.enqueue(2);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
|
||||
EXPECT_EQ(ints.dequeue_end(), 2);
|
||||
EXPECT_EQ(ints.size(), 2);
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
|
||||
EXPECT_EQ(ints.dequeue_end(), 1);
|
||||
EXPECT_EQ(ints.size(), 1);
|
||||
EXPECT_EQ(ints.size(), 1u);
|
||||
|
||||
EXPECT_EQ(ints.dequeue_end(), 0);
|
||||
EXPECT(ints.is_empty());
|
||||
|
|
|
@ -35,14 +35,14 @@ TEST_CASE(basic)
|
|||
ints.enqueue(1);
|
||||
ints.enqueue(2);
|
||||
ints.enqueue(3);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
|
||||
ints.enqueue(4);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints.dequeue(), 2);
|
||||
EXPECT_EQ(ints.dequeue(), 3);
|
||||
EXPECT_EQ(ints.dequeue(), 4);
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(complex_type)
|
||||
|
@ -52,7 +52,7 @@ TEST_CASE(complex_type)
|
|||
strings.enqueue("ABC");
|
||||
strings.enqueue("DEF");
|
||||
|
||||
EXPECT_EQ(strings.size(), 2);
|
||||
EXPECT_EQ(strings.size(), 2u);
|
||||
|
||||
strings.enqueue("abc");
|
||||
strings.enqueue("def");
|
||||
|
@ -69,9 +69,9 @@ TEST_CASE(complex_type_clear)
|
|||
strings.enqueue("xxx");
|
||||
strings.enqueue("xxx");
|
||||
strings.enqueue("xxx");
|
||||
EXPECT_EQ(strings.size(), 5);
|
||||
EXPECT_EQ(strings.size(), 5u);
|
||||
strings.clear();
|
||||
EXPECT_EQ(strings.size(), 0);
|
||||
EXPECT_EQ(strings.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_MAIN(CircularQueue)
|
||||
|
|
|
@ -41,7 +41,7 @@ TEST_CASE(basic)
|
|||
EXPECT_EQ(path.basename(), "ghi.txt");
|
||||
EXPECT_EQ(path.title(), "ghi");
|
||||
EXPECT_EQ(path.extension(), "txt");
|
||||
EXPECT_EQ(path.parts().size(), 3);
|
||||
EXPECT_EQ(path.parts().size(), 3u);
|
||||
EXPECT_EQ(path.parts(), Vector<String>({ "abc", "def", "ghi.txt" }));
|
||||
EXPECT_EQ(path.string(), "/abc/def/ghi.txt");
|
||||
}
|
||||
|
@ -58,21 +58,21 @@ TEST_CASE(relative_paths)
|
|||
FileSystemPath path("simple");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./simple");
|
||||
EXPECT_EQ(path.parts().size(), 2);
|
||||
EXPECT_EQ(path.parts().size(), 2u);
|
||||
EXPECT_EQ(path.basename(), "simple");
|
||||
}
|
||||
{
|
||||
FileSystemPath path("a/relative/path");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./a/relative/path");
|
||||
EXPECT_EQ(path.parts().size(), 4);
|
||||
EXPECT_EQ(path.parts().size(), 4u);
|
||||
EXPECT_EQ(path.basename(), "path");
|
||||
}
|
||||
{
|
||||
FileSystemPath path("./././foo");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./foo");
|
||||
EXPECT_EQ(path.parts().size(), 2);
|
||||
EXPECT_EQ(path.parts().size(), 2u);
|
||||
EXPECT_EQ(path.basename(), "foo");
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ TEST_CASE(relative_paths)
|
|||
FileSystemPath path(".");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), ".");
|
||||
EXPECT_EQ(path.parts().size(), 1);
|
||||
EXPECT_EQ(path.parts().size(), 1u);
|
||||
EXPECT_EQ(path.basename(), ".");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_CASE(construct)
|
|||
{
|
||||
typedef HashMap<int, int> IntIntMap;
|
||||
EXPECT(IntIntMap().is_empty());
|
||||
EXPECT_EQ(IntIntMap().size(), 0);
|
||||
EXPECT_EQ(IntIntMap().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(populate)
|
||||
|
@ -44,7 +44,7 @@ TEST_CASE(populate)
|
|||
number_to_string.set(3, "Three");
|
||||
|
||||
EXPECT_EQ(number_to_string.is_empty(), false);
|
||||
EXPECT_EQ(number_to_string.size(), 3);
|
||||
EXPECT_EQ(number_to_string.size(), 3u);
|
||||
}
|
||||
|
||||
TEST_CASE(range_loop)
|
||||
|
@ -70,11 +70,11 @@ TEST_CASE(map_remove)
|
|||
number_to_string.set(3, "Three");
|
||||
|
||||
number_to_string.remove(1);
|
||||
EXPECT_EQ(number_to_string.size(), 2);
|
||||
EXPECT_EQ(number_to_string.size(), 2u);
|
||||
EXPECT(number_to_string.find(1) == number_to_string.end());
|
||||
|
||||
number_to_string.remove(3);
|
||||
EXPECT_EQ(number_to_string.size(), 1);
|
||||
EXPECT_EQ(number_to_string.size(), 1u);
|
||||
EXPECT(number_to_string.find(3) == number_to_string.end());
|
||||
EXPECT(number_to_string.find(2) != number_to_string.end());
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ TEST_CASE(case_insensitive)
|
|||
EXPECT_EQ(String("nickserv").to_lowercase(), String("NickServ").to_lowercase());
|
||||
casemap.set("nickserv", 3);
|
||||
casemap.set("NickServ", 3);
|
||||
EXPECT_EQ(casemap.size(), 1);
|
||||
EXPECT_EQ(casemap.size(), 1u);
|
||||
}
|
||||
|
||||
TEST_CASE(assert_on_iteration_during_clear)
|
||||
|
@ -128,7 +128,7 @@ TEST_CASE(hashmap_of_nonnullownptr_get)
|
|||
EXPECT_EQ(x.value()->string, "Two");
|
||||
}
|
||||
|
||||
EXPECT_EQ(objects.size(), 3);
|
||||
EXPECT_EQ(objects.size(), 3u);
|
||||
}
|
||||
|
||||
TEST_MAIN(HashMap)
|
||||
|
|
|
@ -41,13 +41,13 @@ TEST_CASE(populate_int)
|
|||
ints.enqueue(1);
|
||||
ints.enqueue(2);
|
||||
ints.enqueue(3);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints.dequeue(), 1);
|
||||
EXPECT_EQ(ints.size(), 2);
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
EXPECT_EQ(ints.dequeue(), 2);
|
||||
EXPECT_EQ(ints.size(), 1);
|
||||
EXPECT_EQ(ints.size(), 1u);
|
||||
EXPECT_EQ(ints.dequeue(), 3);
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(populate_string)
|
||||
|
@ -55,7 +55,7 @@ TEST_CASE(populate_string)
|
|||
Queue<String> strings;
|
||||
strings.enqueue("ABC");
|
||||
strings.enqueue("DEF");
|
||||
EXPECT_EQ(strings.size(), 2);
|
||||
EXPECT_EQ(strings.size(), 2u);
|
||||
EXPECT_EQ(strings.dequeue(), "ABC");
|
||||
EXPECT_EQ(strings.dequeue(), "DEF");
|
||||
EXPECT(strings.is_empty());
|
||||
|
@ -66,7 +66,7 @@ TEST_CASE(order)
|
|||
Queue<String> strings;
|
||||
EXPECT(strings.is_empty());
|
||||
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for (size_t i = 0; i < 10000; ++i) {
|
||||
strings.enqueue(String::number(i));
|
||||
EXPECT_EQ(strings.size(), i + 1);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ TEST_CASE(convert_to_int)
|
|||
AK::StringUtils::convert_to_int("-", ok);
|
||||
EXPECT(!ok);
|
||||
|
||||
int actual = actual = AK::StringUtils::convert_to_int("0", ok);
|
||||
int actual = AK::StringUtils::convert_to_int("0", ok);
|
||||
EXPECT(ok && actual == 0);
|
||||
|
||||
actual = AK::StringUtils::convert_to_int("1", ok);
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_CASE(construct_empty)
|
|||
EXPECT(StringView().is_null());
|
||||
EXPECT(StringView().is_empty());
|
||||
EXPECT(!StringView().characters_without_null_termination());
|
||||
EXPECT_EQ(StringView().length(), size_t { 0 });
|
||||
EXPECT_EQ(StringView().length(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(view_literal)
|
||||
|
@ -87,7 +87,7 @@ TEST_CASE(lines)
|
|||
String test_string = "a\nb\r\nc\rd";
|
||||
StringView test_string_view = test_string.view();
|
||||
Vector<StringView> test_string_vector = test_string_view.lines();
|
||||
EXPECT_EQ(test_string_vector.size(), 4);
|
||||
EXPECT_EQ(test_string_vector.size(), 4u);
|
||||
EXPECT(test_string_vector.at(0) == String("a"));
|
||||
EXPECT(test_string_vector.at(1) == String("b"));
|
||||
EXPECT(test_string_vector.at(2) == String("c"));
|
||||
|
@ -96,7 +96,7 @@ TEST_CASE(lines)
|
|||
test_string = "```\nHello there\r\nHello there\n```";
|
||||
test_string_view = test_string.view();
|
||||
test_string_vector = test_string_view.lines();
|
||||
EXPECT_EQ(test_string_vector.size(), 4);
|
||||
EXPECT_EQ(test_string_vector.size(), 4u);
|
||||
EXPECT(test_string_vector.at(0) == String("```"));
|
||||
EXPECT(test_string_vector.at(1) == String("Hello there"));
|
||||
EXPECT(test_string_vector.at(2) == String("Hello there"));
|
||||
|
@ -105,7 +105,7 @@ TEST_CASE(lines)
|
|||
test_string = "\n\n\n";
|
||||
test_string_view = test_string.view();
|
||||
test_string_vector = test_string_view.lines();
|
||||
EXPECT_EQ(test_string_vector.size(), 3);
|
||||
EXPECT_EQ(test_string_vector.size(), 3u);
|
||||
EXPECT_EQ(test_string_vector.at(0).is_empty(), true);
|
||||
EXPECT_EQ(test_string_vector.at(1).is_empty(), true);
|
||||
EXPECT_EQ(test_string_vector.at(2).is_empty(), true);
|
||||
|
|
|
@ -43,16 +43,16 @@ TEST_CASE(ints)
|
|||
ints.append(1);
|
||||
ints.append(2);
|
||||
ints.append(3);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints.take_last(), 3);
|
||||
EXPECT_EQ(ints.size(), 2);
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
EXPECT_EQ(ints.take_last(), 2);
|
||||
EXPECT_EQ(ints.size(), 1);
|
||||
EXPECT_EQ(ints.size(), 1u);
|
||||
EXPECT_EQ(ints.take_last(), 1);
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
|
||||
ints.clear();
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(strings)
|
||||
|
@ -108,8 +108,8 @@ TEST_CASE(prepend_vector)
|
|||
|
||||
ints.prepend(move(more_ints));
|
||||
|
||||
EXPECT_EQ(ints.size(), 6);
|
||||
EXPECT_EQ(more_ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 6u);
|
||||
EXPECT_EQ(more_ints.size(), 0u);
|
||||
|
||||
EXPECT_EQ(ints[0], 4);
|
||||
EXPECT_EQ(ints[1], 5);
|
||||
|
@ -119,12 +119,12 @@ TEST_CASE(prepend_vector)
|
|||
EXPECT_EQ(ints[5], 3);
|
||||
|
||||
ints.prepend(move(more_ints));
|
||||
EXPECT_EQ(ints.size(), 6);
|
||||
EXPECT_EQ(more_ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 6u);
|
||||
EXPECT_EQ(more_ints.size(), 0u);
|
||||
|
||||
more_ints.prepend(move(ints));
|
||||
EXPECT_EQ(more_ints.size(), 6);
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(more_ints.size(), 6u);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(prepend_vector_object)
|
||||
|
@ -149,17 +149,17 @@ TEST_CASE(prepend_vector_object)
|
|||
objects.empend(make<SubObject>(2));
|
||||
objects.empend(make<SubObject>(3));
|
||||
|
||||
EXPECT_EQ(objects.size(), 3);
|
||||
EXPECT_EQ(objects.size(), 3u);
|
||||
|
||||
Vector<Object> more_objects;
|
||||
more_objects.empend(make<SubObject>(4));
|
||||
more_objects.empend(make<SubObject>(5));
|
||||
more_objects.empend(make<SubObject>(6));
|
||||
EXPECT_EQ(more_objects.size(), 3);
|
||||
EXPECT_EQ(more_objects.size(), 3u);
|
||||
|
||||
objects.prepend(move(more_objects));
|
||||
EXPECT_EQ(more_objects.size(), 0);
|
||||
EXPECT_EQ(objects.size(), 6);
|
||||
EXPECT_EQ(more_objects.size(), 0u);
|
||||
EXPECT_EQ(objects.size(), 6u);
|
||||
|
||||
EXPECT_EQ(objects[0].subobject->value, 4);
|
||||
EXPECT_EQ(objects[1].subobject->value, 5);
|
||||
|
@ -179,7 +179,7 @@ TEST_CASE(vector_compare)
|
|||
same_ints.append(i);
|
||||
}
|
||||
|
||||
EXPECT_EQ(ints.size(), 1000);
|
||||
EXPECT_EQ(ints.size(), 1000u);
|
||||
EXPECT_EQ(ints, same_ints);
|
||||
|
||||
Vector<String> strings;
|
||||
|
@ -190,7 +190,7 @@ TEST_CASE(vector_compare)
|
|||
same_strings.append(String::number(i));
|
||||
}
|
||||
|
||||
EXPECT_EQ(strings.size(), 1000);
|
||||
EXPECT_EQ(strings.size(), 1000u);
|
||||
EXPECT_EQ(strings, same_strings);
|
||||
}
|
||||
|
||||
|
@ -206,18 +206,18 @@ TEST_CASE(grow_past_inline_capacity)
|
|||
|
||||
auto strings = make_vector();
|
||||
|
||||
EXPECT_EQ(strings.size(), 32);
|
||||
EXPECT_EQ(strings.size(), 32u);
|
||||
EXPECT_EQ(strings[31], "31");
|
||||
|
||||
strings.clear();
|
||||
EXPECT_EQ(strings.size(), 0);
|
||||
EXPECT_EQ(strings.capacity(), 16);
|
||||
EXPECT_EQ(strings.size(), 0u);
|
||||
EXPECT_EQ(strings.capacity(), 16u);
|
||||
|
||||
strings = make_vector();
|
||||
|
||||
strings.clear_with_capacity();
|
||||
EXPECT_EQ(strings.size(), 0);
|
||||
EXPECT(strings.capacity() >= 32);
|
||||
EXPECT_EQ(strings.size(), 0u);
|
||||
EXPECT(strings.capacity() >= 32u);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(vector_append_trivial)
|
||||
|
@ -230,7 +230,7 @@ BENCHMARK_CASE(vector_append_trivial)
|
|||
for (int i = 0; i < 100; ++i) {
|
||||
Vector<int> tmp;
|
||||
tmp.append(ints);
|
||||
EXPECT_EQ(tmp.size(), 1000000);
|
||||
EXPECT_EQ(tmp.size(), 1000000u);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ BENCHMARK_CASE(vector_remove_trivial)
|
|||
while (!ints.is_empty()) {
|
||||
ints.remove(0);
|
||||
}
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
EXPECT_EQ(ints.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(vector_remove)
|
||||
|
@ -257,25 +257,25 @@ TEST_CASE(vector_remove)
|
|||
ints.append(5);
|
||||
|
||||
ints.remove(1);
|
||||
EXPECT_EQ(ints.size(), 4);
|
||||
EXPECT_EQ(ints.size(), 4u);
|
||||
EXPECT_EQ(ints[0], 1);
|
||||
EXPECT_EQ(ints[1], 3);
|
||||
EXPECT_EQ(ints[2], 4);
|
||||
EXPECT_EQ(ints[3], 5);
|
||||
|
||||
ints.remove(0);
|
||||
EXPECT_EQ(ints.size(), 3);
|
||||
EXPECT_EQ(ints.size(), 3u);
|
||||
EXPECT_EQ(ints[0], 3);
|
||||
EXPECT_EQ(ints[1], 4);
|
||||
EXPECT_EQ(ints[2], 5);
|
||||
|
||||
ints.take_last();
|
||||
EXPECT_EQ(ints.size(), 2);
|
||||
EXPECT_EQ(ints.size(), 2u);
|
||||
EXPECT_EQ(ints[0], 3);
|
||||
EXPECT_EQ(ints[1], 4);
|
||||
|
||||
ints.take_first();
|
||||
EXPECT_EQ(ints.size(), 1);
|
||||
EXPECT_EQ(ints.size(), 1u);
|
||||
EXPECT_EQ(ints[0], 4);
|
||||
}
|
||||
|
||||
|
@ -287,12 +287,12 @@ TEST_CASE(nonnullownptrvector)
|
|||
NonnullOwnPtrVector<Object> objects;
|
||||
|
||||
objects.append(make<Object>());
|
||||
EXPECT_EQ(objects.size(), 1);
|
||||
EXPECT_EQ(objects.size(), 1u);
|
||||
|
||||
OwnPtr<Object> o = make<Object>();
|
||||
objects.append(o.release_nonnull());
|
||||
EXPECT(o == nullptr);
|
||||
EXPECT_EQ(objects.size(), 2);
|
||||
EXPECT_EQ(objects.size(), 2u);
|
||||
}
|
||||
|
||||
TEST_CASE(insert_trivial)
|
||||
|
@ -304,7 +304,7 @@ TEST_CASE(insert_trivial)
|
|||
ints.append(30);
|
||||
ints.append(40);
|
||||
ints.insert(2, 15);
|
||||
EXPECT_EQ(ints.size(), 6);
|
||||
EXPECT_EQ(ints.size(), 6u);
|
||||
EXPECT_EQ(ints[0], 0);
|
||||
EXPECT_EQ(ints[1], 10);
|
||||
EXPECT_EQ(ints[2], 15);
|
||||
|
|
Loading…
Reference in a new issue