| 100 | } |
| 101 | |
| 102 | static 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 | |
| 139 | int testFStream(int, char*[]) |
| 140 | { |
no test coverage detected
searching dependent graphs…