Missing static build libraries.
[libsub.git] / test / test.cc
index 4c0b8bf8e4c5876b36074dda62afe236a29b52e4..bc2acda81e4e8a786cc0be1db2b29c0f8117b8c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_MODULE libsub_test
+#include "iso6937_tables.h"
+#include "compose.hpp"
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
 #include <fstream>
 #include <string>
-#include "iso6937_tables.h"
+#include <iostream>
 
 using std::string;
 using std::cerr;
@@ -33,7 +35,6 @@ using std::max;
 using std::hex;
 using std::ifstream;
 using std::getline;
-using std::stringstream;
 
 boost::filesystem::path private_test;
 
@@ -63,10 +64,10 @@ check_text (boost::filesystem::path a, boost::filesystem::path b)
        if (!boost::filesystem::exists (b)) {
                cerr << "File not found: " << b << "\n";
        }
-       
+
        BOOST_CHECK (boost::filesystem::exists (a));
        BOOST_CHECK (boost::filesystem::exists (b));
-       
+
        ifstream p (a.c_str ());
        ifstream q (b.c_str ());
 
@@ -91,7 +92,7 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check)
        BOOST_CHECK (ref_file);
        FILE* check_file = fopen (check.string().c_str(), "rb");
        BOOST_CHECK (check_file);
-       
+
        int const buffer_size = 65536;
        uint8_t* ref_buffer = new uint8_t[buffer_size];
        uint8_t* check_buffer = new uint8_t[buffer_size];
@@ -105,9 +106,10 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check)
                BOOST_CHECK_EQUAL (r, this_time);
 
                for (uintmax_t i = 0; i < this_time; ++i) {
-                       stringstream s;
-                       s << "Files differ at offset " << (offset + i) << "; reference is " << hex << ((int) ref_buffer[i]) << ", check is " << ((int) check_buffer[i]);
-                       BOOST_CHECK_MESSAGE (ref_buffer[i] == check_buffer[i], s.str ());
+                       string const s = String::compose (
+                               "Files differ at offset %1; reference is %2, check is %3", (offset + i), ((int) ref_buffer[i]), ((int) check_buffer[i])
+                               );
+                       BOOST_CHECK_MESSAGE (ref_buffer[i] == check_buffer[i], s);
                }
 
                offset += this_time;