Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 1 | |
Zhenkai Zhu | 85dc03d | 2013-01-03 19:22:12 -0800 | [diff] [blame] | 2 | #include "ccnx-name.h" |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 3 | |
| 4 | #define BOOST_TEST_MAIN 1 |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | |
Zhenkai Zhu | 85dc03d | 2013-01-03 19:22:12 -0800 | [diff] [blame] | 8 | using namespace Ccnx; |
| 9 | using namespace std; |
| 10 | using namespace boost; |
Zhenkai Zhu | 85dc03d | 2013-01-03 19:22:12 -0800 | [diff] [blame] | 11 | |
| 12 | BOOST_AUTO_TEST_SUITE(CcnxNameTests) |
| 13 | |
| 14 | BOOST_AUTO_TEST_CASE (CcnxNameTest) |
| 15 | { |
| 16 | Name empty = Name(); |
| 17 | Name root = Name("/"); |
| 18 | BOOST_CHECK_EQUAL(empty, root); |
Zhenkai Zhu | 3b82d43 | 2013-01-03 22:48:40 -0800 | [diff] [blame^] | 19 | BOOST_CHECK_EQUAL(empty, "/"); |
| 20 | BOOST_CHECK_EQUAL(root.size(), 0); |
| 21 | empty.appendComp("hello"); |
| 22 | empty.appendComp("world"); |
| 23 | BOOST_CHECK_EQUAL(empty.size(), 2); |
| 24 | BOOST_CHECK_EQUAL(empty.toString(), "/hello/world"); |
| 25 | empty = empty + root; |
| 26 | BOOST_CHECK_EQUAL(empty.toString(), "/hello/world"); |
| 27 | BOOST_CHECK_EQUAL(empty.getCompAsString(0), "hello"); |
| 28 | BOOST_CHECK_EQUAL(empty.getPartialName(1, 1), Name("/world")); |
| 29 | Name name("/hello/world"); |
| 30 | BOOST_CHECK_EQUAL(empty, name); |
| 31 | BOOST_CHECK_EQUAL(name, Name("/hello") + Name("/world")); |
| 32 | |
| 33 | // Charbuf related stuff will be checked in other place |
Zhenkai Zhu | 85dc03d | 2013-01-03 19:22:12 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | BOOST_AUTO_TEST_CASE (SelectorsTest) |
| 37 | { |
Zhenkai Zhu | 3b82d43 | 2013-01-03 22:48:40 -0800 | [diff] [blame^] | 38 | Selectors s; |
| 39 | BOOST_CHECK(s.isEmpty()); |
Zhenkai Zhu | 85dc03d | 2013-01-03 19:22:12 -0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | BOOST_AUTO_TEST_SUITE_END() |