diff --git a/README.md b/README.md index 784b0bd..be6127a 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,7 @@ On Windows, you need to install MinGW. waf build --shared ### Running unit tests ### -cpp-iniparses uses GoogleTest (http://code.google.com/p/googletest/) - - waf build --test - -Alternatively, we can also explicitly specify the gtest headers and libraries location - - waf build --test --gtest_include=/gtest/include --gtest_lib=/gtest/lib + ./run_tests.sh ### Installing cppiniparser ### waf install diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..f4c06db --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +cd gtest-1.7.0/make +make +cp gtest_main.a libgtest_main.a +cd - +./waf clean +./waf build --test --gtest_include=gtest-1.7.0/include --gtest_lib=gtest-1.7.0/make diff --git a/src/INIParser.cpp b/src/INIParser.cpp index 355f143..f516a8f 100644 --- a/src/INIParser.cpp +++ b/src/INIParser.cpp @@ -41,14 +41,14 @@ INIConfig INIParser::Read(const std::string& filename) { try { std::string line; while (getline(is, line)) { - if (utils::IsSection(line)) { + if (utils::IsEmptyLine(line) || utils::IsComment(line)) { + // ignore it + } else if (utils::IsSection(line)) { section = utils::ParseSection(line); config.AddSection(section); } else if (utils::IsOption(line)) { std::pair option = utils::ParseOption(line); config.AddOption(section, option.first, option.second); - } else if (utils::IsEmptyLine(line) || utils::IsComment(line)) { - // ignore it } else { std::string msg = "Invalid line: " + line; throw INIReaderException(msg.c_str()); diff --git a/test/test1.ini b/test/test1.ini index 922996c..b859fd4 100644 --- a/test/test1.ini +++ b/test/test1.ini @@ -1,9 +1,13 @@ +;========================================================================= ; foo section +;========================================================================= [foo] name=foo msg=hello +;========================================================================= ; bar section +;========================================================================= [bar] name=bar msg=bye