@@ -1510,6 +1510,57 @@ TEST_CASE_METHOD(TApp, "TOMLVector", "[config]") {
15101510 CHECK (three == std::vector<int >({1 , 2 , 3 }));
15111511}
15121512
1513+ TEST_CASE_METHOD (TApp, " TOMLMultiLineVector" , " [config]" ) {
1514+
1515+ TempFile tmptoml{" TestTomlTmp.toml" };
1516+
1517+ app.set_config (" --config" , tmptoml);
1518+
1519+ {
1520+ std::ofstream out{tmptoml};
1521+ out << " #this is a comment line\n " ;
1522+ out << " [default]\n " ;
1523+ out << " two=[\n " ;
1524+ out << " 2, 3\n " ;
1525+ out << " ]\n " ;
1526+ out << " three=[\n\t 1,\n\t 2,\n\t 3\n ]\n " ;
1527+ }
1528+
1529+ std::vector<int > two, three;
1530+ app.add_option (" --two" , two)->expected (2 )->required ();
1531+ app.add_option (" --three" , three)->required ();
1532+
1533+ run ();
1534+
1535+ CHECK (two == std::vector<int >({2 , 3 }));
1536+ CHECK (three == std::vector<int >({1 , 2 , 3 }));
1537+ }
1538+
1539+ TEST_CASE_METHOD (TApp, " TOMLMultiLineVector2" , " [config]" ) {
1540+
1541+ TempFile tmptoml{" TestTomlTmp.toml" };
1542+
1543+ app.set_config (" --config" , tmptoml);
1544+
1545+ {
1546+ std::ofstream out{tmptoml};
1547+ out << " #this is a comment line\n " ;
1548+ out << " [default]\n " ;
1549+ out << " two=[\n " ;
1550+ out << " 2, 3]\n " ;
1551+ out << " three=[\n\t 1,\n\t 2,\n\t 3\n ]\n " ;
1552+ }
1553+
1554+ std::vector<int > two, three;
1555+ app.add_option (" --two" , two)->expected (2 )->required ();
1556+ app.add_option (" --three" , three)->required ();
1557+
1558+ run ();
1559+
1560+ CHECK (two == std::vector<int >({2 , 3 }));
1561+ CHECK (three == std::vector<int >({1 , 2 , 3 }));
1562+ }
1563+
15131564TEST_CASE_METHOD (TApp, " ColonValueSep" , " [config]" ) {
15141565
15151566 TempFile tmpini{" TestIniTmp.ini" };
@@ -1700,6 +1751,30 @@ TEST_CASE_METHOD(TApp, "TOMLStringVector", "[config]") {
17001751 CHECK (three == std::vector<std::string>({" 1" , " 2" , " 3" }));
17011752}
17021753
1754+ TEST_CASE_METHOD (TApp, " TOMLStringVectorMultiline" , " [config]" ) {
1755+
1756+ TempFile tmptoml{" TestTomlTmp.toml" };
1757+
1758+ app.set_config (" --config" , tmptoml);
1759+
1760+ {
1761+ std::ofstream out{tmptoml};
1762+ out << " #this is a comment line\n " ;
1763+ out << " [default]\n " ;
1764+ out << " two=[\n\t\t\" 2\" ,\" 3\" ]\n " ;
1765+ out << " three=[\n \" 1\" ,\n \" 2\" ,\n \" 3\"\n ] \n " ;
1766+ }
1767+
1768+ std::vector<std::string> two, three;
1769+
1770+ app.add_option (" --two" , two)->required ();
1771+ app.add_option (" --three" , three)->required ();
1772+
1773+ run ();
1774+ CHECK (two == std::vector<std::string>({" 2" , " 3" }));
1775+ CHECK (three == std::vector<std::string>({" 1" , " 2" , " 3" }));
1776+ }
1777+
17031778TEST_CASE_METHOD (TApp, " IniVectorCsep" , " [config]" ) {
17041779
17051780 TempFile tmpini{" TestIniTmp.ini" };
0 commit comments