From 5abcfb86bb1aa03b480fb69385837dbbe27dd59f Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 8 Sep 2021 20:39:46 +0200 Subject: [PATCH] Tests - add test for file_read_bin() / file_write_bin() --- test/test_file_rw_bin.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/test_file_rw_bin.cc diff --git a/test/test_file_rw_bin.cc b/test/test_file_rw_bin.cc new file mode 100644 index 0000000..ab0c56d --- /dev/null +++ b/test/test_file_rw_bin.cc @@ -0,0 +1,24 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt +#include +#include + +#include "../src/pEpLog.hh" +#include "../src/std_utils.hh" + +int main(int argc, char* argv[]) +{ + pEp::Adapter::pEpLog::set_enabled(true); + std::string filename = "test_rw.bin"; + + std::vector v_out{}; + for (int i = 0; i < 1000; i++) { + v_out.push_back(pEp::Utils::random_char(0, 255)); + } + + pEp::Utils::file_write_bin(filename, v_out); + + std::vector v_in = pEp::Utils::file_read_bin(filename); + + assert(v_in == v_out); +}