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

Function TestFileRead

src/test/io_test.cpp:10–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include <gtest/gtest.h>
9
10static void TestFileRead(const char *pWritten)
11{
12 const int WrittenLength = str_length(pWritten);
13
14 char aBuf[64] = {0};
15 CTestInfo Info;
16
17 IOHANDLE File = io_open(Info.m_aFilename, IOFLAG_WRITE);
18 ASSERT_TRUE(File);
19 EXPECT_EQ(io_write(File, pWritten, WrittenLength), WrittenLength);
20 EXPECT_FALSE(io_close(File));
21
22 File = io_open(Info.m_aFilename, IOFLAG_READ);
23 ASSERT_TRUE(File);
24 EXPECT_EQ(io_read(File, aBuf, sizeof(aBuf)), WrittenLength);
25 EXPECT_EQ(mem_comp(aBuf, pWritten, WrittenLength), 0);
26 EXPECT_FALSE(io_close(File));
27 EXPECT_FALSE(fs_remove(Info.m_aFilename));
28}
29
30TEST(Io, Read1)
31{

Callers 1

TESTFunction · 0.85

Calls 7

str_lengthFunction · 0.85
io_openFunction · 0.85
io_writeFunction · 0.85
io_closeFunction · 0.85
io_readFunction · 0.85
mem_compFunction · 0.85
fs_removeFunction · 0.85

Tested by

no test coverage detected