File: BtKeepAliveMessageTest.cc

package info (click to toggle)
aria2 1.37.0%2Bdebian-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,128 kB
  • sloc: cpp: 115,006; ansic: 9,140; makefile: 1,466; ruby: 475; python: 373; sh: 260; xml: 176
file content (41 lines) | stat: -rw-r--r-- 982 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "BtKeepAliveMessage.h"
#include <cstring>
#include <cppunit/extensions/HelperMacros.h>

namespace aria2 {

class BtKeepAliveMessageTest : public CppUnit::TestFixture {

  CPPUNIT_TEST_SUITE(BtKeepAliveMessageTest);
  CPPUNIT_TEST(testCreateMessage);
  CPPUNIT_TEST(testToString);
  CPPUNIT_TEST_SUITE_END();

private:
public:
  void setUp() {}

  void testCreateMessage();
  void testToString();
};

CPPUNIT_TEST_SUITE_REGISTRATION(BtKeepAliveMessageTest);

void BtKeepAliveMessageTest::testCreateMessage()
{
  char data[4];
  memset(data, 0, sizeof(data));
  BtKeepAliveMessage message;
  CPPUNIT_ASSERT_EQUAL((uint8_t)99, message.getId());
  auto rawmsg = message.createMessage();
  CPPUNIT_ASSERT_EQUAL((size_t)4, rawmsg.size());
  CPPUNIT_ASSERT(std::equal(std::begin(rawmsg), std::end(rawmsg), data));
}

void BtKeepAliveMessageTest::testToString()
{
  BtKeepAliveMessage msg;
  CPPUNIT_ASSERT_EQUAL(std::string("keep alive"), msg.toString());
}

} // namespace aria2