Nuke warnings in tests
This commit is contained in:
+25
-25
@@ -18,8 +18,8 @@ START_TEST (test_read_file_non_existing_file)
|
||||
content = uc_read_file("non existing file 123765", &len, 1000000000);
|
||||
saved_errno = errno;
|
||||
|
||||
fail_if(content != NULL);
|
||||
fail_if(saved_errno == 0);
|
||||
ck_assert_ptr_null(content);
|
||||
ck_assert_int_ne(saved_errno, 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@@ -31,20 +31,20 @@ START_TEST (test_read_file_simple)
|
||||
ssize_t rc;
|
||||
|
||||
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
|
||||
fail_if(fd == -1);
|
||||
ck_assert_int_ne(fd, -1);
|
||||
|
||||
rc = write(fd, "hello", 5);
|
||||
fail_if(rc != 5, "rc was %ld", (long)rc);
|
||||
ck_assert_int_eq(rc, 5);
|
||||
|
||||
close(fd);
|
||||
|
||||
content = uc_read_file(filename, &len, 1000000000);
|
||||
unlink(filename);
|
||||
|
||||
fail_if(content == NULL);
|
||||
fail_if(len != 5);
|
||||
fail_if(strlen(content) != 5);
|
||||
fail_if(strcmp("hello", content) != 0);
|
||||
ck_assert_ptr_nonnull(content);
|
||||
ck_assert_uint_eq(len, 5);
|
||||
ck_assert_uint_eq(strlen(content), 5);
|
||||
ck_assert_str_eq("hello", content);
|
||||
free(content);
|
||||
}
|
||||
END_TEST
|
||||
@@ -61,7 +61,7 @@ START_TEST (test_read_file_greater_than_max)
|
||||
fail_if(fd == -1);
|
||||
|
||||
rc = write(fd, "hello", 5);
|
||||
fail_if(rc != 5, "rc was %ld", (long)rc);
|
||||
fail_if(rc != 5);
|
||||
|
||||
close(fd);
|
||||
|
||||
@@ -69,8 +69,8 @@ START_TEST (test_read_file_greater_than_max)
|
||||
saved_errno = errno;
|
||||
unlink(filename);
|
||||
|
||||
fail_if(content != NULL);
|
||||
fail_if(saved_errno != EMSGSIZE, "was %d", saved_errno);
|
||||
ck_assert_ptr_null(content);
|
||||
ck_assert_int_eq(saved_errno, EMSGSIZE);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@@ -87,16 +87,16 @@ START_TEST (test_read_file_boundary)
|
||||
fail_if(fd == -1);
|
||||
|
||||
rc = write(fd, buf, sizeof buf);
|
||||
fail_if(rc != sizeof buf, "rc was %ld", (long)rc);
|
||||
ck_assert_uint_eq(rc, sizeof buf);
|
||||
|
||||
close(fd);
|
||||
|
||||
content = uc_read_file(filename, &len, 1000000000);
|
||||
unlink(filename);
|
||||
|
||||
fail_if(content == NULL);
|
||||
fail_if(len != sizeof buf);
|
||||
fail_if(strcmp("foobar", &content[1022]) != 0);
|
||||
ck_assert_ptr_nonnull(content);
|
||||
ck_assert_uint_eq(len, sizeof buf);
|
||||
ck_assert_str_eq("foobar", &content[1022]);
|
||||
free(content);
|
||||
}
|
||||
END_TEST
|
||||
@@ -107,10 +107,10 @@ START_TEST (test_read_file_devnull)
|
||||
size_t len = 123;
|
||||
|
||||
content = uc_read_file("/dev/null", &len, 1024);
|
||||
fail_if(content == NULL);
|
||||
fail_if(len != 0);
|
||||
ck_assert_ptr_nonnull(content);
|
||||
ck_assert_uint_eq(len, 0);
|
||||
free(content);
|
||||
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@@ -125,14 +125,14 @@ START_TEST (test_read_file_too_big)
|
||||
fail_if(fd == -1);
|
||||
|
||||
rc = write(fd, "hello", 5);
|
||||
fail_if(rc != 5, "rc was %ld", (long)rc);
|
||||
fail_if(rc != 5);
|
||||
|
||||
close(fd);
|
||||
|
||||
content = uc_read_file(filename, &len, 4);
|
||||
|
||||
fail_if(errno != EMSGSIZE);
|
||||
fail_if(content != NULL);
|
||||
ck_assert_int_eq(errno, EMSGSIZE);
|
||||
ck_assert_ptr_null(content);
|
||||
|
||||
unlink(filename);
|
||||
}
|
||||
@@ -147,18 +147,18 @@ START_TEST (test_read_file_big)
|
||||
ssize_t rc;
|
||||
|
||||
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
|
||||
fail_if(fd == -1);
|
||||
ck_assert_int_ne(fd, -1);
|
||||
memset(buf, 'a', sizeof buf);
|
||||
|
||||
rc = write(fd, buf, sizeof buf);
|
||||
fail_if(rc != sizeof buf, "rc was %ld", (long)rc);
|
||||
ck_assert_uint_eq(rc, sizeof buf);
|
||||
|
||||
close(fd);
|
||||
|
||||
content = uc_read_file(filename, &len, 4096*16);
|
||||
fail_if(content == NULL);
|
||||
fail_if(len != sizeof buf);
|
||||
fail_if(memcmp(content, buf, sizeof buf) != 0);
|
||||
ck_assert_uint_eq(len, sizeof buf);
|
||||
ck_assert_int_eq(memcmp(content, buf, sizeof buf), 0);
|
||||
|
||||
free(content);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user