1 /* Copyright (C) 2012 The libsigc++ Development Team 2 * 3 * This file is part of libsigc++. 4 * 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. 9 * 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. 14 * 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/>. 17 */ 18 19 #include <string> 20 #include <sstream> 21 22 // Functions used in several test cases in libsigc++. 23 // This is a singleton class. 24 class TestUtilities 25 { 26 public: 27 28 // Non-copyable: 29 TestUtilities(const TestUtilities&) = delete; 30 TestUtilities& operator=(const TestUtilities&) = delete; 31 32 // Non-movable: 33 TestUtilities(TestUtilities&&) = delete; 34 TestUtilities& operator=(TestUtilities&&) = delete; 35 36 static TestUtilities* get_instance(); 37 bool check_command_args(int argc, char* argv[]); 38 void check_result(std::ostringstream& result_stream, const std::string& expected_result); get_verbose()39 bool get_verbose() const { return verbose_; } get_result()40 bool get_result() const { return result_ok_; } 41 42 // When you are searching for memory leaks with valgrind or a similar program, 43 // you avoid a harmless warning by deleting the instance when you're done with it. 44 static bool get_result_and_delete_instance(); 45 46 private: 47 48 49 TestUtilities(); 50 51 static TestUtilities* instance_; 52 bool verbose_; 53 bool result_ok_; 54 int test_number_; 55 }; 56