mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 20:18:22 +08:00
improve read_line and tests
This commit is contained in:
parent
17c3d726d1
commit
1ee029b7f1
@ -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 用于返回数据的缓冲区。
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user