MCPcopy Create free account
hub / github.com/ddnet/ddnet / TestFileLineReaderRaw

Function TestFileLineReaderRaw

src/test/linereader_test.cpp:9–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <gtest/gtest.h>
8
9void TestFileLineReaderRaw(const char *pWritten, unsigned WrittenLength, std::initializer_list<const char *> pReads, bool ExpectSuccess, bool WriteBom)
10{
11 CTestInfo Info;
12 IOHANDLE File = io_open(Info.m_aFilename, IOFLAG_WRITE);
13 ASSERT_TRUE(File);
14 if(WriteBom)
15 {
16 constexpr const unsigned char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
17 EXPECT_EQ(io_write(File, UTF8_BOM, sizeof(UTF8_BOM)), sizeof(UTF8_BOM));
18 }
19 EXPECT_EQ(io_write(File, pWritten, WrittenLength), WrittenLength);
20 EXPECT_FALSE(io_close(File));
21
22 CLineReader LineReader;
23 const bool ActualSuccess = LineReader.OpenFile(io_open(Info.m_aFilename, IOFLAG_READ));
24 ASSERT_EQ(ActualSuccess, ExpectSuccess);
25 if(ActualSuccess)
26 {
27 for(const char *pRead : pReads)
28 {
29 const char *pReadLine = LineReader.Get();
30 ASSERT_TRUE(pReadLine) << "Line reader returned less lines than expected";
31 EXPECT_STREQ(pReadLine, pRead) << "Line reader returned unexpected line";
32 }
33 EXPECT_FALSE(LineReader.Get()) << "Line reader returned more lines than expected";
34 }
35
36 fs_remove(Info.m_aFilename);
37}
38
39void TestFileLineReaderRaw(const char *pWritten, unsigned WrittenLength, std::initializer_list<const char *> pReads, bool ExpectSuccess)
40{

Callers 2

TestFileLineReaderFunction · 0.85
TESTFunction · 0.85

Calls 6

io_openFunction · 0.85
io_writeFunction · 0.85
io_closeFunction · 0.85
fs_removeFunction · 0.85
OpenFileMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected