Go to the documentation of this file.
10 #include <gtest/gtest.h>
19 const std::string a =
"check", b =
"test", c =
"final //comments";
22 EXPECT_STREQ(
"final", first.
read_string(a, b, b).c_str());
27 std::vector<std::string> sections;
29 second.
write(
"one",
"name",
"val");
30 second.
write(
"two",
"names",
"value");
33 if (sections.size() == 2)
35 EXPECT_STREQ(
"one", sections[0].c_str());
36 EXPECT_STREQ(
"two", sections[1].c_str());
42 std::vector<std::string>
names;
44 third.
write(
"sec",
"name",
"val");
45 third.
write(
"sec",
"names",
"value");
48 if (
names.size() == 2)
50 EXPECT_STREQ(
"name",
names[0].c_str());
51 EXPECT_STREQ(
"names",
names[1].c_str());
60 EXPECT_FALSE(third.
keyExists(
"SEC",
"NAMEX"));
66 "# example config file from std::string\n"
81 "key_str = this is a \\\n"
82 "long value that can be \\\n"
83 "split into several lines \\\n"
84 "but read as a single line. \n";
87 "this is a long value that can be split into several lines but read as a "
95 const std::string readStr = cfg.
read_string(
"test",
"key_str",
"");
112 const std::string readStr = cfg.
read_string(
"test",
"key_str",
"");
119 _putenv_s(
"ENV_VAR_MULTIPLIER",
"2");
121 ::setenv(
"ENV_VAR_MULTIPLIER",
"2", 1);
124 const std::string sampleCfgTxt2 =
125 "@define MAXSPEED 10\n"
126 "@define MAXOMEGA -30 \n"
131 "var4=$eval{5*MAXSPEED+MAXOMEGA}\n"
132 "var5 = $eval{ MAXSPEED - MAXOMEGA } \n"
133 "var6=$env{ENV_VAR_MULTIPLIER}\n"
134 "varstr1=MAXSPEED\n";
mrpt::config::CConfigFileMemory CConfigFileMemory
void getAllSections(std::vector< std::string > §ions) const override
Returns a list with all the section names.
void write(const std::string §ion, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
bool keyExists(const std::string §ion, const std::string &key) const
Checks if a given key exists inside a section (case insensitive)
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
void getAllKeys(const std::string §ion, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
mrpt::config::CConfigFile CConfigFile
mrpt::vision::TStereoCalibResults out
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
std::string getTempFileName()
Returns the name of a proposed temporary file name.
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
const std::string sampleCfgTxt
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
std::vector< string > names
const std::string expectedStr
This class allows loading and storing values and vectors of different types from "....
bool sectionExists(const std::string §ion_name) const
Checks if a given section exists (name is case insensitive)
This class implements a config file-like interface over a memory-stored string list.
TEST(CConfigFileMemory, readwrite)
Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020 | |