1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 20:23:55 +00:00
CLI11/tests/IniTest.cpp
Henry Fredrick Schreiner 77071fdb95 Adding tempfile helper
2017-02-13 08:59:53 -05:00

59 lines
1.2 KiB
C++

#include "app_helper.hpp"
#include <cstdio>
#include <sstream>
TEST(StringBased, First) {
std::stringstream ofile;
ofile << "one=three" << std::endl;
ofile << "two=four" << std::endl;
ofile.seekg(0, std::ios::beg);
std::vector<std::string> output = CLI::detail::parse_ini(ofile);
std::vector<std::string> answer = {"--one=three", "--two=four"};
EXPECT_EQ(answer, output);
}
TEST(StringBased, Sections) {
std::stringstream ofile;
ofile << "one=three" << std::endl;
ofile << "[second]" << std::endl;
ofile << " two=four" << std::endl;
ofile.seekg(0, std::ios::beg);
std::vector<std::string> output = CLI::detail::parse_ini(ofile);
std::vector<std::string> answer = {"--one=three", "--second.two=four"};
EXPECT_EQ(answer, output);
}
TEST(StringBased, SpacesSections) {
std::stringstream ofile;
ofile << "one=three" << std::endl;
ofile << std::endl;
ofile << "[second]" << std::endl;
ofile << " " << std::endl;
ofile << " two=four" << std::endl;
ofile.seekg(0, std::ios::beg);
std::vector<std::string> output = CLI::detail::parse_ini(ofile);
std::vector<std::string> answer = {"--one=three", "--second.two=four"};
EXPECT_EQ(answer, output);
}