tftp
try to fix a bug Lorenz told me about in fwrite
This commit is contained in:
@@ -74,4 +74,22 @@ TEST(TFTP, custom_fwrite) {
|
||||
free(write_file.data);
|
||||
write_file.data = NULL;
|
||||
write_file.len = 0;
|
||||
}
|
||||
|
||||
TEST(TFTP, custom_fread_fwrite_suggested_by_Lorentz) {
|
||||
write_file.data = (char*)malloc(21 * sizeof(char));
|
||||
write_file.len = 21;
|
||||
write_file.offset = 0;
|
||||
tftp_custom_fwrite("1234567890123456789", 19, &write_file);
|
||||
|
||||
tftp_custom_fwrite("0987654321", 10, &write_file);
|
||||
EXPECT_EQ(write_file.offset, 20);
|
||||
EXPECT_EQ(write_file.len, 21);
|
||||
EXPECT_EQ(memcmp(write_file.data, "12345678901234567890", 20), 0);
|
||||
free(write_file.data);
|
||||
|
||||
char buf[21];
|
||||
file.offset = 9;
|
||||
tftp_custom_fread(buf, 20, &file);
|
||||
EXPECT_EQ(memcmp(buf, "0", 1), 0);
|
||||
}
|
||||
Reference in New Issue
Block a user