Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
4c84eb18
Commit
4c84eb18
authored
Apr 24, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Array's move ctor.
parent
71a5b7a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
format-test.cc
format-test.cc
+33
-0
No files found.
format-test.cc
View file @
4c84eb18
...
...
@@ -207,6 +207,39 @@ TEST(ArrayTest, Ctor) {
EXPECT_EQ
(
123u
,
array
.
capacity
());
}
#if FMT_USE_RVALUE_REFERENCES
TEST
(
ArrayTest
,
MoveCtor
)
{
Array
<
char
,
5
>
array
;
const
char
test
[]
=
"test"
;
array
.
append
(
test
,
test
+
4
);
{
Array
<
char
,
5
>
array2
(
std
::
move
(
array
));
// Moving shouldn't destroy the inline content of the first array.
EXPECT_EQ
(
test
,
std
::
string
(
&
array
[
0
],
array
.
size
()));
EXPECT_EQ
(
test
,
std
::
string
(
&
array2
[
0
],
array2
.
size
()));
EXPECT_EQ
(
5
,
array2
.
capacity
());
}
array
.
push_back
(
'a'
);
{
Array
<
char
,
5
>
array2
(
std
::
move
(
array
));
// Moving shouldn't destroy the inline content of the first array.
EXPECT_EQ
(
"testa"
,
std
::
string
(
&
array
[
0
],
array
.
size
()));
EXPECT_EQ
(
"testa"
,
std
::
string
(
&
array2
[
0
],
array2
.
size
()));
EXPECT_EQ
(
5
,
array2
.
capacity
());
}
array
.
push_back
(
'b'
);
{
Array
<
char
,
5
>
array2
(
std
::
move
(
array
));
// Moving should rip the guts of the first array.
EXPECT_TRUE
(
!&
array
[
0
]);
EXPECT_EQ
(
"testab"
,
std
::
string
(
&
array2
[
0
],
array2
.
size
()));
EXPECT_GT
(
array2
.
capacity
(),
5
);
}
}
#endif // FMT_USE_RVALUE_REFERENCES
TEST
(
ArrayTest
,
Access
)
{
Array
<
char
,
10
>
array
;
array
[
0
]
=
11
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment