MCPcopy Create free account
hub / github.com/Kitware/CMake / testBOM

Function testBOM

Source/kwsys/testFStream.cxx:68–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66};
67
68static int testBOM()
69{
70 // test various encodings in binary mode
71 for (int i = 0; i < num_test_files; i++) {
72 {
73 kwsys::ofstream out("bom.txt", kwsys::ofstream::binary);
74 out.write(reinterpret_cast<char const*>(expected_bom_data[i] + 1),
75 *expected_bom_data[i]);
76 out.write(reinterpret_cast<char const*>(file_data[i] + 1),
77 file_data[i][0]);
78 }
79
80 kwsys::ifstream in("bom.txt", kwsys::ofstream::binary);
81 kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
82 if (bom != expected_bom[i]) {
83 std::cout << "Unexpected BOM " << i << std::endl;
84 return 1;
85 }
86 char data[max_test_file_size];
87 in.read(data, file_data[i][0]);
88 if (!in.good()) {
89 std::cout << "Unable to read data " << i << std::endl;
90 return 1;
91 }
92
93 if (memcmp(data, file_data[i] + 1, file_data[i][0]) != 0) {
94 std::cout << "Incorrect read data " << i << std::endl;
95 return 1;
96 }
97 }
98
99 return 0;
100}
101
102static int testBOMIO()
103{

Callers 1

testFStreamFunction · 0.85

Calls 4

ReadBOMFunction · 0.85
goodMethod · 0.80
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…