28 namespace bfs = boost::filesystem;
31 TEST ( registrypo, alternativeconstructor ) {
32 unordered_map<std::string, boost::any> v;
34 v[
"raistlin"] = std::string (
"shirak" );
35 v[
"seoman"] = float ( 3.05f );
37 EXPECT_EQ ( j.
get<
int> (
"hobbits" ), 4 );
38 EXPECT_EQ ( j.
get<std::string> (
"raistlin" ),
"shirak" );
39 EXPECT_EQ ( j.
get<
float> (
"seoman" ), 3.05f );
43 TEST ( registrypo, dump ) {
44 unordered_map<std::string, boost::any> v;
45 v[
"hobbits"] = unsigned ( 4 );
46 v[
"raistlin"] = std::string (
"shirak" );
47 v[
"seoman"] = float ( 3.05f );
50 "\n\t\t+hobbits=4\n\t\t+raistlin=shirak\n\t\t+seoman=3.05\n\n" );
54 TEST ( registrypo, alternativegetmethods ) {
55 unordered_map<std::string, boost::any> v;
56 v[
"goblin"] = std::string (
"S,X,V" );
57 v[
"turin"] = std::string (
"X,1,Y,2" );
58 v[
"turinwrong"] = std::string (
"X,A,Y,B" );
59 v[
"turambar"] = std::string (
"" );
60 v[
"smaug"] = std::string (
"T" );
82 EXPECT_EQ ( user_check_ok,
false );
84 unordered_set<std::string> aux = j.
getSetString (
"goblin" );
85 EXPECT_EQ ( aux.size(), 3 );
86 EXPECT_TRUE ( aux.find (
"S" ) != aux.end() );
87 EXPECT_TRUE ( aux.find (
"X" ) != aux.end() );
88 EXPECT_TRUE ( aux.find (
"V" ) != aux.end() );
98 TEST ( registrypo, get_string ) {
99 unordered_map<std::string, boost::any> v;
100 v[
"hobbits"] = std::string (
"file://hobbits" );
102 o <<
"frodo,bilbo" << endl;
104 o <<
"merry" << endl;
107 EXPECT_EQ ( j.
getString (
"hobbits" ),
"frodo,bilbo sam merry" );
108 bfs::remove ( bfs::path (
"hobbits" ) );
118 int main (
int argc,
char **argv ) {
119 ::testing::InitGoogleTest ( &argc, argv );
120 return RUN_ALL_TESTS();
Wrapper stream class that writes to pipes, text files or gzipped files.
int main(int argc, char **argv)
main function. If compiled individualy, will kickoff any tests in this file.
std::vector< std::string > getVectorString(const std::string &key) const
Convenience method that returns a vector of strings taking "," as the separator character.
T get(const std::string &key) const
Returns parsed value associated to key.
TEST(registrypo, alternativeconstructor)
Test alternative constructor for testing.
unordered_map< uint, std::string > getMappedIndexString(const std::string &key) const
Convenience method that returns a hash of strings indexed by position and taking "," as the separator character.
unordered_map< std::string, uint > getMappedStringIndex(const std::string &key) const
Convenience method that returns a hash of indices indexed by string and taking "," as the separator c...
unordered_map< std::string, uint > getPairMappedStringUInt(const std::string &key) const
Convenience method that builds a hash with pairs taking "," as the separator character. Pair elements assumed to be unsigned integers. For instance, –param=X,3,T,5 => hash["X"]=3 and hash["T"]=5.
Static variables for logger. Include only once from main file.
std::string getString(const std::string &key) const
Performs get<string> and checks whether the real value is to be loaded from file (–param=file://.....)
std::string dump(const std::string &decorator_start="", const std::string &decorator_end="")
Dumps all configuration parameters into a string with a reasonably pretty format. ...
Unit testing: google testing common header.
unordered_set< std::string > getSetString(const std::string &key) const
Convenience method that returns a set of strings taking "," as the separator character.
Static variable for custom_assert. Include only once from main file.
void close()
Closes the file.