blob: 5084246c6bcdf7d8584b848cd7820207812c238d [file] [log] [blame]
Alexander Afanasyev72ac2192013-01-03 19:33:43 -08001
Zhenkai Zhu85dc03d2013-01-03 19:22:12 -08002#include "ccnx-name.h"
Alexander Afanasyev72ac2192013-01-03 19:33:43 -08003
4#define BOOST_TEST_MAIN 1
Alexander Afanasyev72ac2192013-01-03 19:33:43 -08005
6#include <boost/test/unit_test.hpp>
7
Zhenkai Zhu85dc03d2013-01-03 19:22:12 -08008using namespace Ccnx;
9using namespace std;
10using namespace boost;
Zhenkai Zhu85dc03d2013-01-03 19:22:12 -080011
12BOOST_AUTO_TEST_SUITE(CcnxNameTests)
13
14BOOST_AUTO_TEST_CASE (CcnxNameTest)
15{
16 Name empty = Name();
17 Name root = Name("/");
18 BOOST_CHECK_EQUAL(empty, root);
Zhenkai Zhu3b82d432013-01-03 22:48:40 -080019 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 Zhu85dc03d2013-01-03 19:22:12 -080034}
35
36BOOST_AUTO_TEST_CASE (SelectorsTest)
37{
Zhenkai Zhu3b82d432013-01-03 22:48:40 -080038 Selectors s;
39 BOOST_CHECK(s.isEmpty());
Zhenkai Zhu85dc03d2013-01-03 19:22:12 -080040}
41
42BOOST_AUTO_TEST_SUITE_END()