TEST_F(kodFileTest, WriteFileWithMultipleEntries) { kod_db_file = estrdup(CreatePath("kod-output-multiple", OUTPUT_DIR).c_str()); add_entry("example.com", "RATE"); add_entry("192.0.2.1", "DENY"); add_entry("192.0.2.5", "RSTR"); /* * Manipulate timestamps. This is a bit of a hack, ideally these * tests should not care about the internal representation. */ kod_db[0]->timestamp = 0xabcd; kod_db[1]->timestamp = 0xabcd; kod_db[2]->timestamp = 0xabcd; write_kod_db(); // Open file and compare sizes and content. ifstream actual(kod_db_file, ios::binary); ifstream expected(CreatePath("kod-expected-multiple", INPUT_DIR).c_str()); ASSERT_TRUE(actual.good()); ASSERT_TRUE(expected.good()); ASSERT_EQ(GetFileSize(expected), GetFileSize(actual)); CompareFileContent(expected, actual); }
void test_WriteFileWithMultipleEntries(void) { kod_db_file = estrdup("kod-output-multiple"); add_entry("example.com", "RATE"); add_entry("192.0.2.1", "DENY"); add_entry("192.0.2.5", "RSTR"); // // Manipulate timestamps. This is a bit of a hack, ideally these // tests should not care about the internal representation. // kod_db[0]->timestamp = 0xabcd; kod_db[1]->timestamp = 0xabcd; kod_db[2]->timestamp = 0xabcd; write_kod_db(); // Open file and compare sizes and content. FILE * actual = fopen(kod_db_file, "rb"); FILE * expected = fopen(CreatePath("kod-expected-multiple", INPUT_DIR),"rb"); TEST_ASSERT_NOT_NULL(actual); TEST_ASSERT_NOT_NULL(expected); TEST_ASSERT_EQUAL(GetFileSize(expected), GetFileSize(actual)); TEST_ASSERT_TRUE(CompareFileContent(expected, actual)); }
// Closes outputFile, and compare contents. void FinishDebugTest(const char *expected, const char *actual) { FILE* fp_a; FILE* fp_e; if (outputFileOpened) { fclose(outputFile); } fp_a = fopen(actual, "rb"); fp_e = fopen(expected, "rb"); if (fp_a != NULL && fp_e != NULL) CompareFileContent(fp_e, fp_a); else fprintf(stderr, "FinishDebugTest: file pointer unexpectedly null.\n"); if (fp_a) fclose(fp_a); if (fp_e) fclose(fp_e); free((void*) expected); free((void*) actual); }
// Closes outputFile, and compare contents. void FinishDebugTest(const char * expected, const char * actual) { if (outputFileOpened) fclose(outputFile); FILE * e = fopen(expected,"rb"); FILE * a = fopen(actual,"rb"); TEST_ASSERT_TRUE(e != NULL); TEST_ASSERT_TRUE(a != NULL); CompareFileContent(e, a); }
/*static*/ status_t FSUtils::CompareFileContent(const Entry& entry1, const Entry& entry2, bool& _equal) { BFile file1; status_t error = _OpenFile(entry1, file1); if (error != B_OK) return error; BFile file2; error = _OpenFile(entry2, file2); if (error != B_OK) return error; return CompareFileContent(file1, file2, _equal); }
TEST_F(kodFileTest, WriteFileWithSingleEntry) { kod_db_file = estrdup(CreatePath("kod-output-single", OUTPUT_DIR).c_str()); add_entry("host1", "DENY"); /* Here we must manipulate the timestamps, so they match the one in * the expected file. */ kod_db[0]->timestamp = 1; write_kod_db(); // Open file and compare sizes. ifstream actual(kod_db_file, ios::binary); ifstream expected(CreatePath("kod-expected-single", INPUT_DIR).c_str()); ASSERT_TRUE(actual.good()); ASSERT_TRUE(expected.good()); ASSERT_EQ(GetFileSize(expected), GetFileSize(actual)); CompareFileContent(expected, actual); }
void test_WriteFileWithSingleEntry(void) { kod_db_file = estrdup("kod-output-single"); add_entry("host1", "DENY"); // Here we must manipulate the timestamps, so they match the one in // the expected file. kod_db[0]->timestamp = 1; write_kod_db(); // Open file and compare sizes. FILE * actual = fopen(kod_db_file, "rb"); FILE * expected = fopen(CreatePath("kod-expected-single", INPUT_DIR),"rb"); TEST_ASSERT_NOT_NULL(actual); TEST_ASSERT_NOT_NULL(expected); TEST_ASSERT_EQUAL(GetFileSize(expected), GetFileSize(actual)); TEST_ASSERT_TRUE(CompareFileContent(expected, actual)); }