NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ndnSIM
ndnSIM documentation
All Attributes
All GlobalValues
All LogComponents
All TraceSources
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
hybi_util.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011, Peter Thorson. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
* * Redistributions of source code must retain the above copyright
7
* notice, this list of conditions and the following disclaimer.
8
* * Redistributions in binary form must reproduce the above copyright
9
* notice, this list of conditions and the following disclaimer in the
10
* documentation and/or other materials provided with the distribution.
11
* * Neither the name of the WebSocket++ Project nor the
12
* names of its contributors may be used to endorse or promote products
13
* derived from this software without specific prior written permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
*
26
*/
27
//#define BOOST_TEST_DYN_LINK
28
#define BOOST_TEST_MODULE hybi_util
29
#include <boost/test/unit_test.hpp>
30
31
#include <iostream>
32
33
#include "../../src/processors/hybi_util.hpp"
34
#include "../../src/network_utilities.hpp"
35
36
BOOST_AUTO_TEST_CASE
( circshift_0 ) {
37
if
(
sizeof
(
size_t
) == 8) {
38
size_t
test
= 0x0123456789abcdef;
39
40
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,0);
41
42
BOOST_CHECK( test == 0x0123456789abcdef);
43
}
else
{
44
size_t
test
= 0x01234567;
45
46
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,0);
47
48
BOOST_CHECK( test == 0x01234567);
49
}
50
}
51
52
BOOST_AUTO_TEST_CASE
( circshift_1 ) {
53
if
(
sizeof
(
size_t
) == 8) {
54
size_t
test
= 0x0123456789abcdef;
55
56
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,1);
57
58
BOOST_CHECK( test == 0xef0123456789abcd);
59
}
else
{
60
size_t
test
= 0x01234567;
61
62
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,1);
63
64
BOOST_CHECK( test == 0x67012345);
65
}
66
}
67
68
BOOST_AUTO_TEST_CASE
( circshift_2 ) {
69
if
(
sizeof
(
size_t
) == 8) {
70
size_t
test
= 0x0123456789abcdef;
71
72
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,2);
73
74
BOOST_CHECK( test == 0xcdef0123456789ab);
75
}
else
{
76
size_t
test
= 0x01234567;
77
78
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,2);
79
80
BOOST_CHECK( test == 0x45670123);
81
}
82
}
83
84
BOOST_AUTO_TEST_CASE
( circshift_3 ) {
85
if
(
sizeof
(
size_t
) == 8) {
86
size_t
test
= 0x0123456789abcdef;
87
88
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,3);
89
90
BOOST_CHECK( test == 0xabcdef0123456789);
91
}
else
{
92
size_t
test
= 0x01234567;
93
94
test =
websocketpp::processor::hybi_util::circshift_prepared_key
(test,3);
95
96
BOOST_CHECK( test == 0x23456701);
97
}
98
}
websocketpp::frame::circshift_prepared_key
size_t circshift_prepared_key(size_t prepared_key, size_t offset)
circularly shifts the supplied prepared masking key by offset bytes
Definition:
frame.hpp:612
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(circshift_0)
Definition:
hybi_util.cpp:36
websocketpp::error::test
Unit testing utility error code.
Definition:
error.hpp:96
ndnSIM
NFD
websocketpp
test
transport
hybi_util.cpp
Generated on Thu Nov 2 2017 03:30:29 for ndnSIM by
1.8.11