check function to make sure that open sections match close sections
| 438 | |
| 439 | // check function to make sure that open sections match close sections |
| 440 | bool checkSections(const std::vector<CLI::ConfigItem> &output) { |
| 441 | std::set<std::string> open; |
| 442 | for(const auto &ci : output) { |
| 443 | if(ci.name == "++") { |
| 444 | auto nm = ci.fullname(); |
| 445 | nm.pop_back(); |
| 446 | nm.pop_back(); |
| 447 | auto rv = open.insert(nm); |
| 448 | if(!rv.second) { |
| 449 | return false; |
| 450 | } |
| 451 | } |
| 452 | if(ci.name == "--") { |
| 453 | auto nm = ci.fullname(); |
| 454 | nm.pop_back(); |
| 455 | nm.pop_back(); |
| 456 | auto rv = open.erase(nm); |
| 457 | if(rv != 1U) { |
| 458 | return false; |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | return open.empty(); |
| 463 | } |
| 464 | TEST_CASE("StringBased: Layers", "[config]") { |
| 465 | std::stringstream ofile; |
| 466 |