MRPT  2.0.0
vector_loadsave_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/core/format.h>
13 #include <test_mrpt_common.h>
14 
15 TEST(file_get_contents, readTestFile)
16 {
17  const std::string fil = mrpt::format(
18  "%s/tests/sample_text_file.txt", mrpt::UNITTEST_BASEDIR.c_str());
19 
20  const std::string contents = mrpt::io::file_get_contents(fil);
21 
22  const std::string expectedContents = "0\n1\n2\n3\nhello\nworld!\n";
23 
24  EXPECT_EQ(contents, expectedContents);
25 }
26 
27 TEST(file_get_contents, throwOnError)
28 {
29  const std::string fil = mrpt::format(
30  "%s/tests/sample_text_file_bis.txt", mrpt::UNITTEST_BASEDIR.c_str());
31 
32  EXPECT_ANY_THROW(mrpt::io::file_get_contents(fil));
33 }
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
std::string file_get_contents(const std::string &fileName)
Loads an entire text file and return its contents as a single std::string.
TEST(file_get_contents, readTestFile)



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020