blob: c97fce8f21f0061f5dc0c03b84e8436d9c51d1ad [file] [log] [blame]
Shuo Chenba793e92014-03-17 17:17:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "../helpers/repo-command-response.hpp"
8
9#include <boost/test/unit_test.hpp>
10
11namespace repo {
12
13BOOST_AUTO_TEST_SUITE(TestRepoCommandResponse)
14
15BOOST_AUTO_TEST_CASE(TestRepoCommandResponse)
16{
17 RepoCommandResponse response;
18 response.setStatusCode(404);
19 response.setStartBlockId(1);
20 response.setEndBlockId(100);
21 response.setProcessId(1234567890);
22 response.setInsertNum(100);
23 response.setDeleteNum(100);
24
25 ndn::Block wire = response.wireEncode();
26
27 // These octets are obtained by the snippet below.
28 // This check is intended to detect unexpected encoding change in the future.
29 //for (ndn::Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
30 // printf("0x%02x, ", *it);
31 //}
32 static const uint8_t expected[] = {
33 0xcf, 0x16, 0xce, 0x04, 0x49, 0x96, 0x02, 0xd2, 0xd0, 0x02,
34 0x01, 0x94, 0xcc, 0x01, 0x01, 0xcd, 0x01, 0x64, 0xd1, 0x01,
35 0x64, 0xd2, 0x01, 0x64
36 };
37
38 BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
39 wire.begin(), wire.end());
40
41 BOOST_REQUIRE_NO_THROW(RepoCommandResponse(wire));
42
43 RepoCommandResponse decoded(wire);
44 BOOST_CHECK_EQUAL(decoded.getStatusCode(), response.getStatusCode());
45 BOOST_CHECK_EQUAL(decoded.getStartBlockId(), response.getStartBlockId());
46 BOOST_CHECK_EQUAL(decoded.getEndBlockId(), response.getEndBlockId());
47 BOOST_CHECK_EQUAL(decoded.getProcessId(), response.getProcessId());
48 BOOST_CHECK_EQUAL(decoded.getInsertNum(), response.getInsertNum());
49 BOOST_CHECK_EQUAL(decoded.getDeleteNum(), response.getDeleteNum());
50}
51
52BOOST_AUTO_TEST_SUITE_END()
53
54} // namespace repo