mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 20:18:22 +08:00
31 lines
901 B
C++
31 lines
901 B
C++
|
#include "tkc/fs.h"
|
|||
|
#include "tkc/mem.h"
|
|||
|
#include "gtest/gtest.h"
|
|||
|
#include "streams/file/istream_file.h"
|
|||
|
|
|||
|
|
|||
|
TEST(IStreamFile, readline) {
|
|||
|
str_t str;
|
|||
|
tk_istream_t* is = tk_istream_file_create("tests/testdata/test_lines.txt");
|
|||
|
|
|||
|
str_init(&str, 1024);
|
|||
|
ASSERT_EQ(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
ASSERT_STREQ(str.str, "");
|
|||
|
|
|||
|
ASSERT_EQ(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
ASSERT_STREQ(str.str, "line2");
|
|||
|
|
|||
|
ASSERT_EQ(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
ASSERT_STREQ(str.str, "");
|
|||
|
|
|||
|
ASSERT_EQ(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
ASSERT_STREQ(str.str, "line4");
|
|||
|
|
|||
|
ASSERT_EQ(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
ASSERT_STREQ(str.str, "line5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
|||
|
|
|||
|
ASSERT_NE(tk_istream_read_line_str(is, &str), RET_OK);
|
|||
|
|
|||
|
object_unref(OBJECT(is));
|
|||
|
}
|