| 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 | |
| 60 | class JsonStringWriter |
no test coverage detected