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

Function testBOMIO

Source/kwsys/testFStream.cxx:102–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102static int testBOMIO()
103{
104 // test various encodings in binary mode
105 for (int i = 0; i < num_test_files; i++) {
106 kwsys::fstream f("bomio.txt",
107 kwsys::fstream::in | kwsys::fstream::out |
108 kwsys::fstream::binary | kwsys::fstream::trunc);
109 f.write(reinterpret_cast<char const*>(expected_bom_data[i] + 1),
110 *expected_bom_data[i]);
111 f.write(reinterpret_cast<char const*>(file_data[i] + 1), file_data[i][0]);
112 if (!f.good()) {
113 std::cout << "Unable to write data " << i << std::endl;
114 return 1;
115 }
116 f.seekp(0);
117
118 kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(f);
119 if (bom != expected_bom[i]) {
120 std::cout << "Unexpected BOM " << i << std::endl;
121 return 1;
122 }
123 char data[max_test_file_size];
124 f.read(data, file_data[i][0]);
125 if (!f.good()) {
126 std::cout << "Unable to read data " << i << std::endl;
127 return 1;
128 }
129
130 if (memcmp(data, file_data[i] + 1, file_data[i][0]) != 0) {
131 std::cout << "Incorrect read data " << i << std::endl;
132 return 1;
133 }
134 }
135
136 return 0;
137}
138
139int testFStream(int, char*[])
140{

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…