1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Tests: Fix compile errors on Clang

Since Clang enables a couple of warnings that we don't have in GCC,
these were not caught before. Included fixes:

- Use correct printf format string for `size_t`
- Don't compare Nonnull(Ref|Own)Ptr` to nullptr
- Fix unsigned int& => unsigned long& conversion
This commit is contained in:
Daniel Bertalan 2021-07-13 16:23:39 +02:00 committed by Andreas Kling
parent a88f7c99fe
commit 6821cd45ed
4 changed files with 4 additions and 7 deletions

View file

@ -16,7 +16,6 @@ struct Object : public RefCounted<Object> {
TEST_CASE(basics)
{
auto object = adopt_ref(*new Object);
EXPECT(object.ptr() != nullptr);
EXPECT_EQ(object->ref_count(), 1u);
object->ref();
EXPECT_EQ(object->ref_count(), 2u);

View file

@ -134,7 +134,7 @@ static void do_random_tests()
0xffffffff,
};
dbgln("Doing a few random syscalls with:");
for (unsigned long& interesting_value : interesting_values) {
for (const auto& interesting_value : interesting_values) {
dbgln(" {0} ({0:p})", interesting_value);
}
for (size_t i = 0; i < fuzz_syscall_count; ++i) {

View file

@ -326,7 +326,7 @@ static long long hex_to_ll(const char* hex)
int main()
{
printf("Running %lu testcases...\n", NUM_TESTCASES);
printf("Running %zu testcases...\n", NUM_TESTCASES);
printf("%3s(%-5s): %16s(%2s) %16s(%2s) %16s(%2s) %16s(%2s) %s\n", "num", "name", "correct", "cs", "builtin", "cs", "old_strtod", "cs", "new_strtod", "cs", "teststring");
int successes = 0;
@ -336,7 +336,7 @@ int main()
if (tc.should_consume == -1) {
tc.should_consume = strlen(tc.test_string);
}
printf("%3lu(%-5s):", i, tc.test_name);
printf("%3zu(%-5s):", i, tc.test_name);
printf(" %s(%2d)", tc.hex, tc.should_consume);
long long expect_ll = hex_to_ll(tc.hex);
@ -350,7 +350,7 @@ int main()
fails += 1;
}
}
printf("Out of %lu tests, saw %d successes and %d fails.\n", NUM_TESTCASES, successes, fails);
printf("Out of %zu tests, saw %d successes and %d fails.\n", NUM_TESTCASES, successes, fails);
if (fails != 0) {
printf("FAIL\n");
return 1;

View file

@ -24,7 +24,6 @@ void insert_and_verify(int);
NonnullRefPtr<SQL::SchemaDef> setup_schema(SQL::Database& db)
{
auto schema = SQL::SchemaDef::construct("TestSchema");
EXPECT(schema != nullptr);
db.add_schema(schema);
return schema;
}
@ -33,7 +32,6 @@ NonnullRefPtr<SQL::SchemaDef> setup_table(SQL::Database& db)
{
auto schema = setup_schema(db);
auto table = SQL::TableDef::construct(schema, "TestTable");
EXPECT(table != nullptr);
db.add_table(table);
table->append_column("TextColumn", SQL::SQLType::Text);
table->append_column("IntColumn", SQL::SQLType::Integer);