1 /* Copyright (C) 2012 The libsigc++ Development Team
3 * This file is part of libsigc++.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 #include "testutilities.h"
24 TestUtilities* TestUtilities::instance_ = nullptr;
26 TestUtilities::TestUtilities()
27 : verbose_(false), result_ok_(true), test_number_(0)
32 TestUtilities* TestUtilities::get_instance()
35 instance_ = new TestUtilities;
40 bool TestUtilities::check_command_args(int argc, char* argv[])
42 bool go_on = true; // Whether the caller shall continue program execution.
43 bool print_help = false;
44 for (int argi = 1; argi < argc; ++argi)
46 if (std::strcmp(argv[argi], "-v") == 0 || std::strcmp(argv[argi], "--verbose") == 0)
54 if (!(std::strcmp(argv[argi], "-h") == 0 || std::strcmp(argv[argi], "--help") == 0))
57 std::cout << "Unknown command argument: " << argv[argi] << std::endl;
63 std::cout << "Usage: " << argv[0] << " [-h|--help] [-v|--verbose]" << std::endl;
68 void TestUtilities::check_result(std::ostringstream& result_stream,
69 const std::string& expected_result)
72 std::cout << result_stream.str() << std::endl;
75 if (expected_result != result_stream.str())
77 std::cerr << " Test " << test_number_ << std::endl;
78 std::cerr << "Expected \"" << expected_result << "\"" << std::endl;
79 std::cerr << "Got \"" << result_stream.str() << "\"" << std::endl;
82 result_stream.str("");
86 bool TestUtilities::get_result_and_delete_instance()
88 const bool result = instance_ ? instance_->result_ok_ : true;