FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SFML/test/Network/Socket.test.cpp at master · criptych/SFML · GitHub
criptych
/
SFML
Public
forked from
SFML/SFML
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
SFML
/
test
/
Network
/
Socket.test.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
103 lines (88 loc) · 2.81 KB
Breadcrumbs
SFML
/
test
/
Network
/
Socket.test.cpp
Copy path
File metadata and controls
103 lines (88 loc) · 2.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
include
<
SFML/Network/Socket.hpp
>
#
include
<
catch2/catch_test_macros.hpp
>
#
include
<
type_traits
>
class
TestSocket
:
public
sf
::Socket
{
public:
TestSocket
() : sf::Socket(sf::Socket::Type::Udp)
{
}
using
sf::Socket::close;
using
sf::Socket::create;
using
sf::Socket::getNativeHandle;
};
TEST_CASE
(
"
[Network] sf::Socket
"
)
{
SECTION
(
"
Type traits
"
)
{
STATIC_CHECK
(!std::is_constructible_v<sf::Socket>);
STATIC_CHECK
(!std::is_copy_constructible_v<sf::Socket>);
STATIC_CHECK
(!std::is_copy_assignable_v<sf::Socket>);
STATIC_CHECK
(std::is_nothrow_move_constructible_v<sf::Socket>);
STATIC_CHECK
(std::is_nothrow_move_assignable_v<sf::Socket>);
}
SECTION
(
"
Constants
"
)
{
STATIC_CHECK
(sf::Socket::AnyPort ==
0
);
}
const
auto
invalidHandle =
static_cast
<sf::SocketHandle>(-
1
);
SECTION
(
"
Construction
"
)
{
const
TestSocket testSocket;
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() == invalidHandle);
}
SECTION
(
"
Move semantics
"
)
{
SECTION
(
"
Construction
"
)
{
TestSocket movedTestSocket;
movedTestSocket.
setBlocking
(
false
);
movedTestSocket.
create
();
const
TestSocket
testSocket
(
std::move
(movedTestSocket));
CHECK
(!testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() != invalidHandle);
}
SECTION
(
"
Assignment
"
)
{
TestSocket movedTestSocket;
movedTestSocket.
setBlocking
(
false
);
movedTestSocket.
create
();
TestSocket testSocket;
testSocket =
std::move
(movedTestSocket);
CHECK
(!testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() != invalidHandle);
}
}
SECTION
(
"
Set/get blocking
"
)
{
TestSocket testSocket;
testSocket.
setBlocking
(
false
);
CHECK
(!testSocket.
isBlocking
());
}
SECTION
(
"
create()
"
)
{
TestSocket testSocket;
testSocket.
create
();
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() != invalidHandle);
//
Recreate socket to ensure nothing changed
testSocket.
create
();
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() != invalidHandle);
}
SECTION
(
"
close()
"
)
{
TestSocket testSocket;
testSocket.
create
();
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() != invalidHandle);
testSocket.
close
();
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() == invalidHandle);
//
Reclose socket to ensure nothing changed
testSocket.
close
();
CHECK
(testSocket.
isBlocking
());
CHECK
(testSocket.
getNativeHandle
() == invalidHandle);
}
}
Back
|
FazBrowse Home
|
New Git URL