Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
dd1adf83
Verified
Commit
dd1adf83
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: add test for FileWriter and FileReader
parent
f295c71f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
F files
Pipeline
#11820
passed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#11821
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+1
-0
1 addition, 0 deletions
test/CMakeLists.txt
test/test_file_streaming.cpp
+42
-0
42 additions, 0 deletions
test/test_file_streaming.cpp
with
43 additions
and
0 deletions
test/CMakeLists.txt
+
1
−
0
View file @
dd1adf83
...
...
@@ -23,6 +23,7 @@ set(test_cases
test_configuration
test_connection
test_entity
test_file_streaming
test_info
test_protobuf
test_transaction
...
...
This diff is collapsed.
Click to expand it.
test/test_file_streaming.cpp
0 → 100644
+
42
−
0
View file @
dd1adf83
#include
"caosdb/filestreaming/FileWriter.h"
#include
"caosdb/filestreaming/FileReader.h"
#include
<boost/filesystem/operations.hpp>
// for exists, file_size, remove
#include
<boost/filesystem/path.hpp>
// for path
#include
<boost/filesystem/path_traits.hpp>
// for filesystem
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, AssertionResult
#include
<string>
// for string
namespace
fs
=
boost
::
filesystem
;
namespace
FileExchange
{
static
const
fs
::
path
test_file_name
(
"this_is_a_test_file_remove_me.dat"
);
class
test_file_streaming
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
void
TearDown
()
override
{
fs
::
remove
(
test_file_name
);
}
};
TEST_F
(
test_file_streaming
,
test_file_writer_reader
)
{
ASSERT_FALSE
(
fs
::
exists
(
test_file_name
));
FileWriter
writer
(
test_file_name
);
std
::
string
buffer_out
(
1024
,
'c'
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
writer
.
write
(
buffer_out
);
EXPECT_EQ
(
fs
::
file_size
(
test_file_name
),
1024
*
(
i
+
1
));
}
FileReader
reader
(
test_file_name
);
std
::
string
buffer_in
(
1024
,
'\0'
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
reader
.
read
(
buffer_in
);
EXPECT_EQ
(
buffer_in
,
std
::
string
(
1024
,
'c'
));
}
}
}
// namespace FileExchange
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment