Stun Server
Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
testdatastream.cpp
Go to the documentation of this file.
1
/*
2
Copyright 2011 John Selbie
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
#include "
commonincludes.hpp
"
18
#include "
stuncore.h
"
19
20
#include "
testdatastream.h
"
21
22
23
// This test validates the code in stuncore\datastream.cpp
24
HRESULT
CTestDataStream::Run
()
25
{
26
CDataStream
stream;
27
HRESULT
hr;
28
29
const
char
* str1 =
"ABCDEFGHIJ"
;
30
const
char
* str2 =
"KLMNOPQRSTUVW"
;
31
const
char
* str3 =
"mnop"
;
32
const
char
* str4 =
"XYZ"
;
33
char
ch1=
' '
, ch2=
' '
, ch3=
' '
;
34
35
36
Chk
(stream.
Write
(str1, strlen(str1)));
37
Chk
(stream.
Write
(str2, strlen(str2)));
38
Chk
(stream.
SeekDirect
(12));
// seek to "M"
39
Chk
(stream.
Write
(str3, strlen(str3)));
40
Chk
(stream.
SeekDirect
(stream.
GetSize
()));
41
Chk
(stream.
Write
(str4, strlen(str4)));
42
Chk
(stream.
WriteUint8
(0));
43
44
stream.
SeekDirect
(9);
45
46
stream.
ReadInt8
((int8_t*)&ch1);
47
48
ChkIf
(ch1 !=
'J'
,
E_FAIL
);
49
Chk
(stream.
ReadInt8
((int8_t*)&ch2));
50
ChkIf
(ch2 !=
'K'
,
E_FAIL
);
51
52
stream.
SeekRelative
(1);
53
stream.
ReadInt8
((int8_t*)&ch3);
54
ChkIf
(ch3 !=
'm'
,
E_FAIL
);
55
56
Cleanup:
57
return
hr;
58
59
60
}
commonincludes.hpp
Chk
#define Chk(expr)
Definition:
chkmacros.h:53
CDataStream::SeekRelative
HRESULT SeekRelative(int nOffset)
Definition:
datastream.cpp:207
CDataStream
Definition:
datastream.h:24
ChkIf
#define ChkIf(expr, hrerror)
Definition:
chkmacros.h:63
stuncore.h
HRESULT
int32_t HRESULT
Definition:
hresult.h:22
CTestDataStream::Run
virtual HRESULT Run()
Definition:
testdatastream.cpp:24
CDataStream::Write
HRESULT Write(const void *data, size_t size)
Definition:
datastream.cpp:138
CDataStream::SeekDirect
HRESULT SeekDirect(size_t pos)
Definition:
datastream.cpp:187
E_FAIL
#define E_FAIL
Definition:
hresult.h:56
testdatastream.h
CDataStream::GetSize
size_t GetSize()
Definition:
datastream.cpp:182
CDataStream::ReadInt8
HRESULT ReadInt8(int8_t *pVal)
Definition:
datastream.h:63
CDataStream::WriteUint8
HRESULT WriteUint8(uint8_t val)
Definition:
datastream.h:48
testcode
testdatastream.cpp
Generated by
1.8.11