FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SFML/test/System/MemoryInputStream.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
/
System
/
MemoryInputStream.test.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
92 lines (77 loc) · 3.19 KB
Breadcrumbs
SFML
/
test
/
System
/
MemoryInputStream.test.cpp
Copy path
File metadata and controls
92 lines (77 loc) · 3.19 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
#
include
<
SFML/System/MemoryInputStream.hpp
>
#
include
<
catch2/catch_test_macros.hpp
>
#
include
<
array
>
#
include
<
ostream
>
#
include
<
string_view
>
TEST_CASE
(
"
[System] sf::MemoryInputStream
"
)
{
SECTION
(
"
Type traits
"
)
{
STATIC_CHECK
(std::is_copy_constructible_v<sf::MemoryInputStream>);
STATIC_CHECK
(std::is_copy_assignable_v<sf::MemoryInputStream>);
STATIC_CHECK
(std::is_nothrow_move_constructible_v<sf::MemoryInputStream>);
STATIC_CHECK
(std::is_nothrow_move_assignable_v<sf::MemoryInputStream>);
}
using
namespace
std
::literals::string_view_literals
;
SECTION
(
"
Construction
"
)
{
SECTION
(
"
Null data
"
)
{
sf::MemoryInputStream
memoryInputStream
(
nullptr
,
0
);
CHECK
(memoryInputStream.
read
(
nullptr
,
0
) == std::
nullopt
);
CHECK
(memoryInputStream.
seek
(
0
) == std::
nullopt
);
CHECK
(memoryInputStream.
tell
() == std::
nullopt
);
CHECK
(memoryInputStream.
getSize
() == std::
nullopt
);
}
static
constexpr
auto
input =
"
hello world
"
sv;
SECTION
(
"
Zero length
"
)
{
sf::MemoryInputStream
memoryInputStream
(input.
data
(),
0
);
CHECK
(memoryInputStream.
tell
().
value
() ==
0
);
CHECK
(memoryInputStream.
getSize
().
value
() ==
0
);
}
SECTION
(
"
Full length
"
)
{
sf::MemoryInputStream
memoryInputStream
(input.
data
(), input.
size
());
CHECK
(memoryInputStream.
tell
().
value
() ==
0
);
CHECK
(memoryInputStream.
getSize
().
value
() == input.
size
());
}
}
SECTION
(
"
read()
"
)
{
static
constexpr
auto
input =
"
hello world
"
sv;
sf::MemoryInputStream
memoryInputStream
(input.
data
(), input.
size
());
CHECK
(memoryInputStream.
tell
().
value
() ==
0
);
CHECK
(memoryInputStream.
getSize
().
value
() == input.
size
());
//
Read within input
std::array<
char
,
32
> output{};
CHECK
(memoryInputStream.
read
(output.
data
(),
5
).
value
() ==
5
);
CHECK
(
std::string_view
(output.
data
(),
5
) ==
"
hello
"
sv);
CHECK
(memoryInputStream.
tell
().
value
() ==
5
);
CHECK
(memoryInputStream.
getSize
().
value
() == input.
size
());
//
Read beyond input
CHECK
(memoryInputStream.
read
(output.
data
(),
100
).
value
() ==
6
);
CHECK
(
std::string_view
(output.
data
(),
6
) ==
"
world
"
sv);
CHECK
(memoryInputStream.
tell
().
value
() ==
11
);
CHECK
(memoryInputStream.
getSize
().
value
() == input.
size
());
}
SECTION
(
"
seek()
"
)
{
static
constexpr
auto
input =
"
We Love SFML!
"
sv;
sf::MemoryInputStream
memoryInputStream
(input.
data
(), input.
size
());
CHECK
(memoryInputStream.
tell
().
value
() ==
0
);
CHECK
(memoryInputStream.
getSize
().
value
() == input.
size
());
SECTION
(
"
Seek within input
"
)
{
CHECK
(memoryInputStream.
seek
(
0
).
value
() ==
0
);
CHECK
(memoryInputStream.
tell
().
value
() ==
0
);
CHECK
(memoryInputStream.
seek
(
5
).
value
() ==
5
);
CHECK
(memoryInputStream.
tell
().
value
() ==
5
);
}
SECTION
(
"
Seek beyond input
"
)
{
CHECK
(memoryInputStream.
seek
(
1'000
).
value
() == input.
size
());
CHECK
(memoryInputStream.
tell
().
value
() == input.
size
());
}
}
}
Back
|
FazBrowse Home
|
New Git URL