SpiecsEngine
 
Loading...
Searching...
No Matches

◆ TEST() [17/59]

SpicesTest::TEST ( FileLibraryTest ,
Read_Line  )

Testing Spices::FileLibrary::Read_Line.

Definition at line 138 of file FileLibrary_test.h.

138 {
139
141
142 Spices::FileHandle handle{};
143 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Open("premake5.lua", Spices::FileModes::FILE_MODE_READ, false, &handle), true);
144
145 EXPECT_EQ(handle.is_valid, true);
146 EXPECT_NE(handle.handle, nullptr);
147
148 // First Line.
149 {
150 char data[100];
151 uint64_t bytes;
152 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read_Line(&handle, 1000, data, &bytes), true);
153 EXPECT_EQ(bytes, 29);
154
155 std::string firstLineRead(data, bytes);
156 std::string firstLine = "-- @file SpicesTest Premake.\n";
157
158 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
159 }
160
161 // Second Line.
162 {
163 char data[100];
164 uint64_t bytes;
165 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read_Line(&handle, 1000, data, &bytes), true);
166 EXPECT_EQ(bytes, 61);
167
168 std::string firstLineRead(data, bytes);
169 std::string firstLine = "-- @brief Defines details of the UintTest Solution Building.\n";
170
171 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
172 }
173
174 // Third Line.
175 {
176 char data[100];
177 uint64_t bytes;
178 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read_Line(&handle, 1000, data, &bytes), true);
179 EXPECT_EQ(bytes, 32);
180
181 std::string firstLineRead(data, bytes);
182 std::string firstLine = "-- @author The Cherno & Spices.\n";
183
184 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
185 }
186
188 }
#define SPICESTEST_PROFILE_FUNCTION()
static bool FileLibrary_Open(const char *path, FileModes mode, bool binary, FileHandle *out_handle)
Open the file using given string.
static void FileLibrary_Close(FileHandle *handle)
Close the file by the file handle.
static bool FileLibrary_Read_Line(const FileHandle *handle, uint64_t max_length, char *line_buf, uint64_t *out_line_length)
Read one line from the current file handle pointer, and move pointer the same size.
@ FILE_MODE_READ
model : read
Definition FileLibrary.h:37
This Struct is FILE* handle pointer Wrapper.
Definition FileLibrary.h:15

References Spices::FILE_MODE_READ, Spices::FileLibrary::FileLibrary_Close(), Spices::FileLibrary::FileLibrary_Open(), Spices::FileLibrary::FileLibrary_Read_Line(), Spices::FileHandle::handle, and Spices::FileHandle::is_valid.