| 63 | } |
| 64 | |
| 65 | void testIntIO(const IntDescriptor& id_out) { |
| 66 | |
| 67 | std::string data_file_name = "int_data.dat"; |
| 68 | std::string header_file_name = "int_header_H"; |
| 69 | |
| 70 | amrex::Vector<int> idata_out; |
| 71 | for (int i = -99; i <= 100; ++i) { |
| 72 | idata_out.push_back(i); |
| 73 | } |
| 74 | |
| 75 | std::ofstream ofs; |
| 76 | ofs.open(data_file_name.c_str(), std::ios::out|std::ios::binary); |
| 77 | writeIntData(idata_out.data(), idata_out.size(), ofs, id_out); |
| 78 | ofs.close(); |
| 79 | |
| 80 | ofs.open(header_file_name.c_str(), std::ios::out); |
| 81 | ofs << id_out << "\n"; |
| 82 | ofs.close(); |
| 83 | |
| 84 | IntDescriptor id_in; |
| 85 | std::ifstream ifs; |
| 86 | ifs.open(header_file_name.c_str(), std::ios::in); |
| 87 | ifs >> id_in; |
| 88 | ifs.close(); |
| 89 | |
| 90 | AMREX_ALWAYS_ASSERT(id_out == id_in); |
| 91 | |
| 92 | amrex::Vector<int> idata_in(idata_out.size()); |
| 93 | ifs.open(data_file_name.c_str(), std::ios::in|std::ios::binary); |
| 94 | readIntData(idata_in.data(), idata_in.size(), ifs, id_in); |
| 95 | ifs.close(); |
| 96 | |
| 97 | for (int i = 0; i < static_cast<int>(idata_in.size()); ++i) { |
| 98 | AMREX_ALWAYS_ASSERT(idata_in[i] == idata_out[i]); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void testLongIO(const IntDescriptor& id_out) { |
| 103 |
no test coverage detected