| 159 | //------------------------------------------------------------------------------ |
| 160 | |
| 161 | static void runTest( |
| 162 | InputMethod input_method, |
| 163 | const char* input_filename, |
| 164 | FileFormat::FileFormat input_file_format, |
| 165 | OutputMethod output_method, |
| 166 | FileFormat::FileFormat output_file_format, |
| 167 | const std::vector<const char*>* args, |
| 168 | bool should_succeed, |
| 169 | const char* reference_filename = nullptr, |
| 170 | const char* error_message = nullptr) |
| 171 | { |
| 172 | boost::filesystem::path input_pathname = "../test/data"; |
| 173 | input_pathname /= input_filename; |
| 174 | |
| 175 | const boost::filesystem::path output_pathname = |
| 176 | FileUtil::getTempFilename(FileFormat::getFileExt(output_file_format).c_str()); |
| 177 | |
| 178 | const boost::filesystem::path stdout_pathname = |
| 179 | output_method == OutputMethod::File ? |
| 180 | FileUtil::getTempFilename(".txt") : |
| 181 | FileUtil::getTempFilename(FileFormat::getFileExt(output_file_format).c_str()); |
| 182 | |
| 183 | const boost::filesystem::path stderr_pathname = |
| 184 | FileUtil::getTempFilename(".txt"); |
| 185 | |
| 186 | // Ensure temporary files are deleted at end of test. |
| 187 | FileDeleter output_file_deleter(output_pathname); |
| 188 | FileDeleter stdout_file_deleter(stdout_pathname); |
| 189 | FileDeleter stderr_file_deleter(stderr_pathname); |
| 190 | |
| 191 | std::string command_line; |
| 192 | |
| 193 | if (input_method == InputMethod::File) { |
| 194 | command_line = "./audiowaveform"; |
| 195 | command_line += " -i " + input_pathname.string(); |
| 196 | } |
| 197 | else if (input_method == InputMethod::Pipe) { |
| 198 | command_line = "cat "; |
| 199 | command_line += input_pathname.string(); |
| 200 | command_line += " | ./audiowaveform"; |
| 201 | command_line += " --input-format "; |
| 202 | command_line += FileFormat::toString(input_file_format); |
| 203 | } |
| 204 | else { |
| 205 | command_line = "./audiowaveform"; |
| 206 | command_line += " --input-format "; |
| 207 | command_line += FileFormat::toString(input_file_format); |
| 208 | } |
| 209 | |
| 210 | if (output_method == OutputMethod::File) { |
| 211 | command_line += " -o "; |
| 212 | command_line += output_pathname.string(); |
| 213 | } |
| 214 | else { |
| 215 | command_line += " --output-format "; |
| 216 | command_line += FileFormat::toString(output_file_format); |
| 217 | } |
| 218 |
no test coverage detected