diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-06 11:21:23 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-06 11:22:23 +0100 |
commit | b866582d98701f997125ae6d8af2e1b4fd28c401 (patch) | |
tree | d14999a5e179de48c2ebfd24b9d73412ef9656ce | |
parent | 75a6b27f7381d49563bfa034bea9d2918d14a995 (diff) | |
download | serenity-b866582d98701f997125ae6d8af2e1b4fd28c401.zip |
AK: Fix all the warnings in the AK tests
-rw-r--r-- | AK/Tests/TestCircularDeque.cpp | 17 | ||||
-rw-r--r-- | AK/Tests/TestCircularQueue.cpp | 12 | ||||
-rw-r--r-- | AK/Tests/TestFileSystemPath.cpp | 10 | ||||
-rw-r--r-- | AK/Tests/TestHashMap.cpp | 12 | ||||
-rw-r--r-- | AK/Tests/TestQueue.cpp | 12 | ||||
-rw-r--r-- | AK/Tests/TestStringUtils.cpp | 2 | ||||
-rw-r--r-- | AK/Tests/TestStringView.cpp | 8 | ||||
-rw-r--r-- | AK/Tests/TestVector.cpp | 62 |
8 files changed, 68 insertions, 67 deletions
diff --git a/AK/Tests/TestCircularDeque.cpp b/AK/Tests/TestCircularDeque.cpp index a6b236c940..7a9d7070b1 100644 --- a/AK/Tests/TestCircularDeque.cpp +++ b/AK/Tests/TestCircularDeque.cpp @@ -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()); diff --git a/AK/Tests/TestCircularQueue.cpp b/AK/Tests/TestCircularQueue.cpp index 3451282071..00d5e3be96 100644 --- a/AK/Tests/TestCircularQueue.cpp +++ b/AK/Tests/TestCircularQueue.cpp @@ -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) diff --git a/AK/Tests/TestFileSystemPath.cpp b/AK/Tests/TestFileSystemPath.cpp index fcf5ed398f..2c8ec62d13 100644 --- a/AK/Tests/TestFileSystemPath.cpp +++ b/AK/Tests/TestFileSystemPath.cpp @@ -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(), "."); } } diff --git a/AK/Tests/TestHashMap.cpp b/AK/Tests/TestHashMap.cpp index a476e1d815..e6ee902d84 100644 --- a/AK/Tests/TestHashMap.cpp +++ b/AK/Tests/TestHashMap.cpp @@ -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) diff --git a/AK/Tests/TestQueue.cpp b/AK/Tests/TestQueue.cpp index 1697c43d30..7d198ce183 100644 --- a/AK/Tests/TestQueue.cpp +++ b/AK/Tests/TestQueue.cpp @@ -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); } diff --git a/AK/Tests/TestStringUtils.cpp b/AK/Tests/TestStringUtils.cpp index c7b699e030..a284e86b2c 100644 --- a/AK/Tests/TestStringUtils.cpp +++ b/AK/Tests/TestStringUtils.cpp @@ -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); diff --git a/AK/Tests/TestStringView.cpp b/AK/Tests/TestStringView.cpp index a9e032470e..53f2704b46 100644 --- a/AK/Tests/TestStringView.cpp +++ b/AK/Tests/TestStringView.cpp @@ -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); diff --git a/AK/Tests/TestVector.cpp b/AK/Tests/TestVector.cpp index 74f3166742..facff343cf 100644 --- a/AK/Tests/TestVector.cpp +++ b/AK/Tests/TestVector.cpp @@ -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); |