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

Method Expect

src/test/jsonwriter_test.cpp:29–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 void Expect(const char *pExpected)
30 {
31 ASSERT_TRUE(m_pJson);
32 delete m_pJson;
33 m_pJson = nullptr;
34
35 IOHANDLE GotFile = io_open(m_aOutputFilename, IOFLAG_READ);
36 ASSERT_TRUE(GotFile);
37 char *pOutput = io_read_all_str(GotFile);
38 io_close(GotFile);
39 ASSERT_TRUE(pOutput);
40 EXPECT_STREQ(pOutput, pExpected);
41 bool Correct = str_comp(pOutput, pExpected) == 0;
42 free(pOutput);
43
44 if(!Correct)
45 {
46 char aFilename[IO_MAX_PATH_LENGTH];
47 m_Info.Filename(aFilename, sizeof(aFilename), "-expected.json");
48 IOHANDLE ExpectedFile = io_open(aFilename, IOFLAG_WRITE);
49 ASSERT_TRUE(ExpectedFile);
50 io_write(ExpectedFile, pExpected, str_length(pExpected));
51 io_close(ExpectedFile);
52 }
53 else
54 {
55 fs_remove(m_aOutputFilename);
56 }
57 }
58};
59
60class JsonStringWriter

Callers 1

TYPED_TESTFunction · 0.45

Calls 8

io_openFunction · 0.85
io_read_all_strFunction · 0.85
io_closeFunction · 0.85
str_compFunction · 0.85
io_writeFunction · 0.85
str_lengthFunction · 0.85
fs_removeFunction · 0.85
FilenameMethod · 0.45

Tested by

no test coverage detected