SpiecsEngine
 
Loading...
Searching...
No Matches

◆ TEST() [15/59]

SpicesTest::TEST ( FileLibraryTest ,
Read  )

Testing Spices::FileLibrary::Read.

Definition at line 83 of file FileLibrary_test.h.

83 {
84
86
87 Spices::FileHandle handle{};
88 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Open("premake5.lua", Spices::FileModes::FILE_MODE_READ, false, &handle), true);
89
90 EXPECT_EQ(handle.is_valid, true);
91 EXPECT_NE(handle.handle, nullptr);
92
93 // First Line.
94 {
95 char data[29];
96 uint64_t bytes;
97 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read(&handle, 29, data, &bytes), true);
98 EXPECT_EQ(bytes, 29);
99
100 std::string firstLineRead(data, bytes);
101 std::string firstLine = "-- @file SpicesTest Premake.\n";
102
103 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
104 }
105
106 // Second Line.
107 {
108 char data[61];
109 uint64_t bytes;
110 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read(&handle, 61, data, &bytes), true);
111 EXPECT_EQ(bytes, 61);
112
113 std::string firstLineRead(data, bytes);
114 std::string firstLine = "-- @brief Defines details of the UintTest Solution Building.\n";
115
116 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
117 }
118
119 // Third Line.
120 {
121 char data[32];
122 uint64_t bytes;
123 EXPECT_EQ(Spices::FileLibrary::FileLibrary_Read(&handle, 32, data, &bytes), true);
124 EXPECT_EQ(bytes, 32);
125
126 std::string firstLineRead(data, bytes);
127 std::string firstLine = "-- @author The Cherno & Spices.\n";
128
129 EXPECT_STREQ(firstLineRead.c_str(), firstLine.c_str());
130 }
131
133 }
#define SPICESTEST_PROFILE_FUNCTION()
static bool FileLibrary_Read(const FileHandle *handle, uint64_t data_size, void *out_data, uint64_t *out_bytes_read)
Read Specific size of data form the current file handle pointer, and move pointer the same size.
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.
@ 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(), Spices::FileHandle::handle, and Spices::FileHandle::is_valid.