management: Adding nfd::FaceStatus data structure
Change-Id: I45585a17a4163931c38ece5621d12489aa6a3b73
Refs: #1328
diff --git a/tests/management/test-nfd-control.cpp b/tests/management/test-nfd-control.cpp
index 299620e..68df397 100644
--- a/tests/management/test-nfd-control.cpp
+++ b/tests/management/test-nfd-control.cpp
@@ -8,6 +8,7 @@
#include "management/nfd-fib-management-options.hpp"
#include "management/nfd-face-management-options.hpp"
#include "management/nfd-face-event-notification.hpp"
+#include "management/nfd-face-status.hpp"
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
@@ -46,6 +47,13 @@
0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33
};
+const uint8_t TestFaceStatus[] = {
+ 0x80, 0x27, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a,
+ 0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a,
+ 0x36, 0x33, 0x36, 0x33, 0x91, 0x01, 0x0a, 0x90, 0x01, 0x14, 0x92, 0x01,
+ 0x1e, 0x93, 0x02, 0x01, 0x90
+};
+
// ControlResponse
BOOST_AUTO_TEST_CASE(ControlResponseEncode)
@@ -182,6 +190,38 @@
}
}
+BOOST_AUTO_TEST_CASE(FaceStatusEncodingDecoding)
+{
+ {
+ FaceStatus faceStatus(100, "tcp4://127.0.0.1:6363", 10, 20, 30, 400);
+ BOOST_REQUIRE_NO_THROW(faceStatus.wireEncode());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(TestFaceStatus,
+ TestFaceStatus + sizeof(TestFaceStatus),
+ faceStatus.wireEncode().begin(), faceStatus.wireEncode().end());
+
+ std::ostringstream os;
+ os << faceStatus;
+ BOOST_CHECK_EQUAL(os.str(), "FaceStatus(FaceID: 100, Uri: tcp4://127.0.0.1:6363, "
+ "Counters: 10|20|30|400)");
+ }
+
+ {
+ Block block(TestFaceStatus, sizeof(TestFaceStatus));
+ BOOST_REQUIRE_NO_THROW((FaceStatus(block)));
+
+ FaceStatus faceStatus(block);
+
+ BOOST_CHECK_EQUAL(faceStatus.getFaceId(), 100);
+ BOOST_CHECK_EQUAL(faceStatus.getUri(), "tcp4://127.0.0.1:6363");
+
+ BOOST_CHECK_EQUAL(faceStatus.getInInterest(), 10);
+ BOOST_CHECK_EQUAL(faceStatus.getInData(), 20);
+ BOOST_CHECK_EQUAL(faceStatus.getOutInterest(), 30);
+ BOOST_CHECK_EQUAL(faceStatus.getOutData(), 400);
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace nfd