1 /*
2 Copyright 2019 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/core/nvp.hpp>
9 #include <boost/core/lightweight_test.hpp>
10
test()11 void test()
12 {
13 const char* n = "name";
14 int v = 1;
15 boost::nvp<int> p(n, v);
16 BOOST_TEST_EQ(p.name(), n);
17 BOOST_TEST_EQ(p.value(), 1);
18 BOOST_TEST_EQ(&p.value(), &v);
19 }
20
test_factory()21 void test_factory()
22 {
23 const char* n = "name";
24 int v = 1;
25 boost::nvp<int> p = boost::make_nvp(n, v);
26 BOOST_TEST_EQ(p.name(), n);
27 BOOST_TEST_EQ(p.value(), 1);
28 BOOST_TEST_EQ(&p.value(), &v);
29 }
30
test_macro()31 void test_macro()
32 {
33 int v = 1;
34 boost::nvp<int> p = BOOST_NVP(v);
35 BOOST_TEST_CSTR_EQ(p.name(), "v");
36 BOOST_TEST_EQ(p.value(), 1);
37 BOOST_TEST_EQ(&p.value(), &v);
38 }
39
main()40 int main()
41 {
42 test();
43 test_factory();
44 test_macro();
45 return boost::report_errors();
46 }
47