1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 12:43:52 +00:00
CLI11/tests/IniTest.cpp
2017-02-11 10:07:23 -05:00

65 lines
1.3 KiB
C++

#ifdef CLI_SINGLE_FILE
#include "CLI11.hpp"
#else
#include "CLI/CLI.hpp"
#endif
#include "gtest/gtest.h"
#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);
}