28 const char *paths[] = {
30 "bin/data/sample.json",
31 "../bin/data/sample.json",
32 "../../bin/data/sample.json",
33 "../../../bin/data/sample.json" 36 for (
size_t i = 0; i <
sizeof(paths) /
sizeof(paths[0]); i++) {
37 fp = fopen(paths[i],
"rb");
45 fseek(fp, 0, SEEK_END);
46 length_ =
static_cast<size_t>(ftell(fp));
47 fseek(fp, 0, SEEK_SET);
48 json_ =
static_cast<char*
>(malloc(length_ + 1));
49 size_t readLength = fread(json_, 1, length_, fp);
50 json_[readLength] =
'\0';
72 FILE *fp = fopen(filename_,
"rb");
77 for (
size_t i = 0; i < length_; i++) {
78 EXPECT_EQ(json_[i], s.
Peek());
79 EXPECT_EQ(json_[i], s.
Peek());
80 EXPECT_EQ(json_[i], s.
Take());
83 EXPECT_EQ(length_, s.
Tell());
84 EXPECT_EQ(
'\0', s.
Peek());
90 char filename[L_tmpnam];
95 for (
size_t i = 0; i < length_; i++)
101 fp = fopen(filename,
"rb");
104 for (
size_t i = 0; i < length_; i++)
105 EXPECT_EQ(json_[i], is.
Take());
107 EXPECT_EQ(length_, is.
Tell());
FILE * TempFile(char *filename)
Wrapper of C file stream for input using fread().
virtual ~FileStreamTest()
File byte stream for input using fread().
TEST_F(FileStreamTest, FileReadStream)