1 // -*- C++ -*- 2 3 // Copyright (C) 2005-2016 Free Software Foundation, Inc. 4 // 5 // This file is part of the GNU ISO C++ Library. This library is free 6 // software; you can redistribute it and/or modify it under the terms 7 // of the GNU General Public License as published by the Free Software 8 // Foundation; either version 3, or (at your option) any later 9 // version. 10 11 // This library is distributed in the hope that it will be useful, but 12 // WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 // General Public License for more details. 15 16 // You should have received a copy of the GNU General Public License 17 // along with this library; see the file COPYING3. If not see 18 // <http://www.gnu.org/licenses/>. 19 20 21 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 22 23 // Permission to use, copy, modify, sell, and distribute this software 24 // is hereby granted without fee, provided that the above copyright 25 // notice appears in all copies, and that both that copyright notice 26 // and this permission notice appear in supporting documentation. None 27 // of the above authors, nor IBM Haifa Research Laboratories, make any 28 // representation about the suitability of this software for any 29 // purpose. It is provided "as is" without express or implied 30 // warranty. 31 32 /** 33 * @file trait.hpp 34 * Contains traits for a random regression test 35 * for a specific container type. 36 */ 37 38 #ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP 39 #define PB_DS_REGRESSION_TEST_TRAIT_HPP 40 41 #include <regression/trait/erase_if_fn.hpp> 42 43 namespace __gnu_pbds 44 { 45 namespace test 46 { 47 namespace detail 48 { 49 template<typename Cntnr> 50 struct regression_test_traits 51 { 52 typedef typename Cntnr::value_type value_type; 53 typedef typename Cntnr::const_reference const_reference; 54 typedef __gnu_pbds::test::native_priority_queue<std::string, true> native_type; 55 typedef typename native_type::value_type native_value_type; 56 57 template<typename T> 58 struct erase_if_fn : public regression_test_erase_if_fn<T> 59 { }; 60 61 template<typename Gen> 62 static value_type generate_value__gnu_pbds::test::detail::regression_test_traits63 generate_value(Gen& r_gen, size_t max) 64 { return basic_type(r_gen, max); } 65 66 static native_value_type native_value__gnu_pbds::test::detail::regression_test_traits67 native_value(const_reference r_val) 68 { return native_value_type(r_val); } 69 70 static bool cmp__gnu_pbds::test::detail::regression_test_traits71 cmp(const_reference r_val, const native_value_type& r_native_val) 72 { return val_to_string(r_val) == r_native_val; } 73 74 static std::string val_to_string__gnu_pbds::test::detail::regression_test_traits75 val_to_string(const_reference r_val) 76 { return std::string(r_val); } 77 }; 78 } // namespace detail 79 } // namespace test 80 } // namespace __gnu_pbds 81 82 #endif 83