bool OptionHandler::convertWaveformData( const boost::filesystem::path& input_filename, const boost::filesystem::path& output_filename, const Options& options) { WaveformBuffer buffer; if (!buffer.load(input_filename.c_str())) { return false; } const int bits = options.hasBits() ? options.getBits() : buffer.getBits(); bool success = true; const boost::filesystem::path output_file_ext = output_filename.extension(); if (output_file_ext == ".json") { success = buffer.saveAsJson(output_filename.c_str(), bits); } else if (output_file_ext == ".txt") { success = buffer.saveAsText(output_filename.c_str(), bits); } return success; }
void GdImageRendererTest::testImageRendering(bool axis_labels) { const char* filename = temp_filename_.getFilename(); ASSERT_NE(nullptr, filename); // Ensure temporary file is deleted at end of test. FileDeleter deleter(filename); bool result = buffer_.load("../test/data/test_file_stereo_8bit_64spp.dat"); ASSERT_TRUE(result); const WaveformColors& colors = audacityWaveformColors; result = renderer_.create(buffer_, 5.0, 1000, 300, colors, axis_labels); // zoom: 128 ASSERT_TRUE(result); result = renderer_.saveAsPng(filename); ASSERT_TRUE(result); struct stat info; int stat_result = stat(filename, &info); ASSERT_THAT(stat_result, Eq(0)); ASSERT_THAT(info.st_size, Gt(0)); ASSERT_FALSE(output.str().empty()); ASSERT_TRUE(error.str().empty()); }