mirror of
https://github.com/boostorg/property_map.git
synced 2026-01-19 04:22:15 +00:00
Switch from deprecated test to Lightweight Test
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <boost/property_map/compose_property_map.hpp>
|
||||
|
||||
#include <boost/property_map/function_property_map.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void concept_checks()
|
||||
{
|
||||
@@ -63,11 +63,11 @@ void pointer_pmap_check()
|
||||
boost::compose_property_map<double*, const int*> cpm(v, idx);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
BOOST_CHECK(get(cpm, i) == static_cast<double>(i));
|
||||
BOOST_TEST(get(cpm, i) == static_cast<double>(i));
|
||||
++cpm[i];
|
||||
BOOST_CHECK(cpm[i] == static_cast<double>(i + 1));
|
||||
BOOST_TEST(cpm[i] == static_cast<double>(i + 1));
|
||||
put(cpm, i, 42.);
|
||||
BOOST_CHECK(cpm[i] == 42.);
|
||||
BOOST_TEST(cpm[i] == 42.);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,15 +87,15 @@ void readable_pmap_checks()
|
||||
cpm(modulo_add_one(5), modulo_add_one(5));
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
BOOST_CHECK(get(cpm, i) == (i + 2) % 5);
|
||||
BOOST_TEST(get(cpm, i) == (i + 2) % 5);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int, char**)
|
||||
main()
|
||||
{
|
||||
concept_checks();
|
||||
pointer_pmap_check();
|
||||
readable_pmap_checks();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
#endif
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <boost/property_map/dynamic_property_map.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
@@ -30,7 +30,7 @@
|
||||
// WARNING: This code leaks memory. For testing purposes only!
|
||||
// WARNING: This code uses library internals. For testing purposes only!
|
||||
boost::shared_ptr<boost::dynamic_property_map>
|
||||
string2string_gen(const std::string& name,
|
||||
string2string_gen(const std::string&,
|
||||
const boost::any&,
|
||||
const boost::any&) {
|
||||
typedef std::map<std::string,std::string> map_t;
|
||||
@@ -51,7 +51,7 @@ string2string_gen(const std::string& name,
|
||||
}
|
||||
|
||||
|
||||
int test_main(int,char**) {
|
||||
int main() {
|
||||
|
||||
// build property maps using associative_property_map
|
||||
|
||||
@@ -81,30 +81,30 @@ int test_main(int,char**) {
|
||||
using boost::type;
|
||||
// Get tests
|
||||
{
|
||||
BOOST_CHECK(get("int",properties,std::string("one")) == "1");
|
||||
BOOST_TEST(get("int",properties,std::string("one")) == "1");
|
||||
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
BOOST_CHECK(boost::get<int>("int",properties,std::string("one")) == 1);
|
||||
BOOST_TEST(boost::get<int>("int",properties,std::string("one")) == 1);
|
||||
#endif
|
||||
BOOST_CHECK(get("int",properties,std::string("one"), type<int>()) == 1);
|
||||
BOOST_CHECK(get("double",properties,5.3) == "five point three");
|
||||
BOOST_TEST(get("int",properties,std::string("one"), type<int>()) == 1);
|
||||
BOOST_TEST(get("double",properties,5.3) == "five point three");
|
||||
}
|
||||
|
||||
// Put tests
|
||||
{
|
||||
put("int",properties,std::string("five"),6);
|
||||
BOOST_CHECK(get("int",properties,std::string("five")) == "6");
|
||||
BOOST_TEST(get("int",properties,std::string("five")) == "6");
|
||||
put("int",properties,std::string("five"),std::string("5"));
|
||||
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
BOOST_CHECK(get<int>("int",properties,std::string("five")) == 5);
|
||||
BOOST_TEST(get<int>("int",properties,std::string("five")) == 5);
|
||||
#endif
|
||||
BOOST_CHECK(get("int",properties,std::string("five"),type<int>()) == 5);
|
||||
BOOST_TEST(get("int",properties,std::string("five"),type<int>()) == 5);
|
||||
put("double",properties,3.14,std::string("3.14159"));
|
||||
BOOST_CHECK(get("double",properties,3.14) == "3.14159");
|
||||
BOOST_TEST(get("double",properties,3.14) == "3.14159");
|
||||
put("double",properties,3.14,std::string("pi"));
|
||||
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
BOOST_CHECK(get<std::string>("double",properties,3.14) == "pi");
|
||||
BOOST_TEST(get<std::string>("double",properties,3.14) == "pi");
|
||||
#endif
|
||||
BOOST_CHECK(get("double",properties,3.14,type<std::string>()) == "pi");
|
||||
BOOST_TEST(get("double",properties,3.14,type<std::string>()) == "pi");
|
||||
}
|
||||
|
||||
// Nonexistent property
|
||||
@@ -124,15 +124,15 @@ int test_main(int,char**) {
|
||||
{
|
||||
boost::dynamic_properties props(&string2string_gen);
|
||||
put("nada",props,std::string("3.14"),std::string("pi"));
|
||||
BOOST_CHECK(get("nada",props,std::string("3.14")) == "pi");
|
||||
BOOST_TEST(get("nada",props,std::string("3.14")) == "pi");
|
||||
}
|
||||
|
||||
// Use the ignore_other_properties generator
|
||||
{
|
||||
boost::dynamic_properties props(&boost::ignore_other_properties);
|
||||
bool value = put("nada",props,std::string("3.14"),std::string("pi"));
|
||||
BOOST_CHECK(value == false);
|
||||
BOOST_TEST(value == false);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/property_map/function_property_map.hpp>
|
||||
#include <boost/concept/assert.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
template <typename T>
|
||||
@@ -30,7 +30,7 @@ struct return_fixed_ref {
|
||||
int& operator()(const T&) const {return *ptr;}
|
||||
};
|
||||
|
||||
int test_main(int, char**) {
|
||||
int main() {
|
||||
using namespace boost;
|
||||
BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept<function_property_map<add1<int>, int>, int>));
|
||||
BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept<function_property_map<add1<int>, int, double>, int>));
|
||||
@@ -45,22 +45,22 @@ int test_main(int, char**) {
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::property_traits<function_property_map<add1_val<int>, int> >::category, boost::readable_property_map_tag>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::property_traits<function_property_map<return_fixed_ref<int>, int> >::category, boost::lvalue_property_map_tag>::value));
|
||||
|
||||
BOOST_CHECK(get(function_property_map<add1<int>, int>(), 3) == 4);
|
||||
BOOST_CHECK(get(function_property_map<add1<int>, int>(add1<int>()), 4) == 5);
|
||||
BOOST_CHECK(get(make_function_property_map<int>(add1<int>()), 5) == 6);
|
||||
BOOST_CHECK(get(function_property_map<add1_val<int>, int>(), 3) == 4);
|
||||
BOOST_CHECK(get(function_property_map<add1_val<int>, int>(add1_val<int>()), 4) == 5);
|
||||
BOOST_CHECK(get(make_function_property_map<int>(add1_val<int>()), 5) == 6);
|
||||
BOOST_TEST(get(function_property_map<add1<int>, int>(), 3) == 4);
|
||||
BOOST_TEST(get(function_property_map<add1<int>, int>(add1<int>()), 4) == 5);
|
||||
BOOST_TEST(get(make_function_property_map<int>(add1<int>()), 5) == 6);
|
||||
BOOST_TEST(get(function_property_map<add1_val<int>, int>(), 3) == 4);
|
||||
BOOST_TEST(get(function_property_map<add1_val<int>, int>(add1_val<int>()), 4) == 5);
|
||||
BOOST_TEST(get(make_function_property_map<int>(add1_val<int>()), 5) == 6);
|
||||
int val;
|
||||
const function_property_map<return_fixed_ref<int>, int> pm = return_fixed_ref<int>((&val));
|
||||
put(pm, 1, 6);
|
||||
BOOST_CHECK(get(pm, 2) == 6);
|
||||
BOOST_CHECK((get(pm, 3) = 7) == 7);
|
||||
BOOST_CHECK(get(pm, 4) == 7);
|
||||
BOOST_TEST(get(pm, 2) == 6);
|
||||
BOOST_TEST((get(pm, 3) = 7) == 7);
|
||||
BOOST_TEST(get(pm, 4) == 7);
|
||||
const function_property_map<return_fixed_ref<int>, int> pm2 = pm; // Check shallow copying
|
||||
BOOST_CHECK(get(pm2, 5) == 7);
|
||||
BOOST_TEST(get(pm2, 5) == 7);
|
||||
put(pm2, 3, 1);
|
||||
BOOST_CHECK(get(pm, 1) == 1);
|
||||
BOOST_TEST(get(pm, 1) == 1);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <boost/property_map/transform_value_property_map.hpp>
|
||||
#include <boost/concept/assert.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
// Ensure this is not default constructible
|
||||
@@ -34,7 +34,7 @@ struct return_fixed_ref {
|
||||
int& operator()(const T&) const {return *ptr;}
|
||||
};
|
||||
|
||||
int test_main(int, char**) {
|
||||
int main() {
|
||||
using namespace boost;
|
||||
typedef function_property_map<times2, int> PM;
|
||||
PM orig_pm(times2(0));
|
||||
@@ -51,22 +51,22 @@ int test_main(int, char**) {
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::property_traits<transform_value_property_map<add1_val<int>, PM> >::category, boost::readable_property_map_tag>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::property_traits<transform_value_property_map<return_fixed_ref<int>, PM> >::category, boost::lvalue_property_map_tag>::value));
|
||||
|
||||
BOOST_CHECK(get(transform_value_property_map<add1<int>, PM>(add1<int>(), orig_pm), 3) == 7);
|
||||
BOOST_CHECK(get(transform_value_property_map<add1<int>, PM>(add1<int>(), orig_pm), 4) == 9);
|
||||
BOOST_CHECK(get(make_transform_value_property_map(add1<int>(), orig_pm), 5) == 11);
|
||||
BOOST_CHECK(get(transform_value_property_map<add1_val<int>, PM>(add1_val<int>(), orig_pm), 3) == 7);
|
||||
BOOST_CHECK(get(transform_value_property_map<add1_val<int>, PM>(add1_val<int>(), orig_pm), 4) == 9);
|
||||
BOOST_CHECK(get(make_transform_value_property_map<int>(add1_val<int>(), orig_pm), 5) == 11);
|
||||
BOOST_TEST(get(transform_value_property_map<add1<int>, PM>(add1<int>(), orig_pm), 3) == 7);
|
||||
BOOST_TEST(get(transform_value_property_map<add1<int>, PM>(add1<int>(), orig_pm), 4) == 9);
|
||||
BOOST_TEST(get(make_transform_value_property_map(add1<int>(), orig_pm), 5) == 11);
|
||||
BOOST_TEST(get(transform_value_property_map<add1_val<int>, PM>(add1_val<int>(), orig_pm), 3) == 7);
|
||||
BOOST_TEST(get(transform_value_property_map<add1_val<int>, PM>(add1_val<int>(), orig_pm), 4) == 9);
|
||||
BOOST_TEST(get(make_transform_value_property_map<int>(add1_val<int>(), orig_pm), 5) == 11);
|
||||
int val;
|
||||
const transform_value_property_map<return_fixed_ref<int>, PM> pm(return_fixed_ref<int>((&val)), orig_pm);
|
||||
put(pm, 1, 6);
|
||||
BOOST_CHECK(get(pm, 2) == 6);
|
||||
BOOST_CHECK((get(pm, 3) = 7) == 7);
|
||||
BOOST_CHECK(get(pm, 4) == 7);
|
||||
BOOST_TEST(get(pm, 2) == 6);
|
||||
BOOST_TEST((get(pm, 3) = 7) == 7);
|
||||
BOOST_TEST(get(pm, 4) == 7);
|
||||
const transform_value_property_map<return_fixed_ref<int>, PM> pm2 = pm; // Check shallow copying
|
||||
BOOST_CHECK(get(pm2, 5) == 7);
|
||||
BOOST_TEST(get(pm2, 5) == 7);
|
||||
put(pm2, 3, 1);
|
||||
BOOST_CHECK(get(pm, 1) == 1);
|
||||
BOOST_TEST(get(pm, 1) == 1);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user