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

Function Expect

src/test/csv_test.cpp:9–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <gtest/gtest.h>
8
9static void Expect(int NumColumns, const char *const *ppColumns, const char *pExpected)
10{
11 CTestInfo Info;
12
13 IOHANDLE File = io_open(Info.m_aFilename, IOFLAG_WRITE);
14 ASSERT_TRUE(File);
15 CsvWrite(File, NumColumns, ppColumns);
16 io_close(File);
17
18 char aBuf[1024];
19 File = io_open(Info.m_aFilename, IOFLAG_READ);
20 ASSERT_TRUE(File);
21 int Read = io_read(File, aBuf, sizeof(aBuf));
22 io_close(File);
23 fs_remove(Info.m_aFilename);
24
25 ASSERT_TRUE(Read >= 1);
26 Read -= 1;
27 ASSERT_EQ(aBuf[Read], '\n');
28 aBuf[Read] = 0;
29
30#if defined(CONF_FAMILY_WINDOWS)
31 ASSERT_TRUE(Read >= 1);
32 Read -= 1;
33 ASSERT_EQ(aBuf[Read], '\r');
34 aBuf[Read] = 0;
35#endif
36
37 for(int i = 0; i < Read; i++)
38 {
39 EXPECT_NE(aBuf[i], 0);
40 }
41 EXPECT_STREQ(aBuf, pExpected);
42}
43
44TEST(Csv, Simple)
45{

Callers 3

TEST_FFunction · 0.85
TEST_FFunction · 0.85
TESTFunction · 0.85

Calls 5

io_openFunction · 0.85
CsvWriteFunction · 0.85
io_closeFunction · 0.85
io_readFunction · 0.85
fs_removeFunction · 0.85

Tested by

no test coverage detected