improve read_line and tests

This commit is contained in:
lixianjing 2020-12-10 17:49:13 +08:00
parent 17c3d726d1
commit 1ee029b7f1
2 changed files with 5 additions and 4 deletions

View File

@ -150,6 +150,7 @@ int32_t fs_file_read(fs_file_t* file, void* buffer, uint32_t size);
* @method fs_file_read_line
*
*
* > Windows下
*
* @param {fs_file_t*} file
* @param {char*} buffer

View File

@ -45,7 +45,7 @@ TEST(Fs, read_line1) {
file_write(filename, str, strlen(str));
fs_file_t* f = fs_open_file(os_fs(), filename, "r");
fs_file_t* f = fs_open_file(os_fs(), filename, "rb");
ASSERT_EQ(fs_file_read_line(f, buff, sizeof(buff)-1), 1);
ASSERT_STREQ(buff, "1");
@ -82,7 +82,7 @@ TEST(Fs, read_line2) {
file_write(filename, str, strlen(str));
fs_file_t* f = fs_open_file(os_fs(), filename, "r");
fs_file_t* f = fs_open_file(os_fs(), filename, "rb");
ASSERT_EQ(fs_file_read_line(f, buff, sizeof(buff)-1), 127);
ASSERT_EQ(fs_file_eof(f), FALSE);
@ -103,7 +103,7 @@ TEST(Fs, read_line3) {
file_write(filename, str, strlen(str));
fs_file_t* f = fs_open_file(os_fs(), filename, "r");
fs_file_t* f = fs_open_file(os_fs(), filename, "rb");
ASSERT_EQ(fs_file_read_line(f, buff, sizeof(buff)-1), 128);
ASSERT_EQ(fs_file_eof(f), FALSE);
@ -124,7 +124,7 @@ TEST(Fs, read_line4) {
file_write(filename, str, strlen(str));
fs_file_t* f = fs_open_file(os_fs(), filename, "r");
fs_file_t* f = fs_open_file(os_fs(), filename, "rb");
ASSERT_EQ(fs_file_read_line(f, buff, sizeof(buff)-1), 127);
ASSERT_EQ(fs_file_read_line(f, buff, sizeof(buff)-1), 3);