Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 4 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 5 | * |
| 6 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 7 | * |
| 8 | */ |
| 9 | |
Jan Kundrát | a33cf08 | 2019-03-28 11:55:57 +0100 | [diff] [blame] | 10 | #include "trompeloeil_doctest.h" |
Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 11 | #include "parser.hpp" |
| 12 | #include "static_schema.hpp" |
| 13 | |
| 14 | TEST_CASE("enum completion") |
| 15 | { |
| 16 | auto schema = std::make_shared<StaticSchema>(); |
| 17 | schema->addModule("mod"); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame^] | 18 | schema->addContainer("/", "mod:contA"); |
| 19 | schema->addLeafEnum("/", "mod:leafEnum", {"lala", "lol", "data", "coze"}); |
| 20 | schema->addLeafEnum("/mod:contA", "mod:leafInCont", {"abc", "def"}); |
| 21 | schema->addList("/", "mod:list", {"number"}); |
| 22 | schema->addLeafEnum("/mod:list", "mod:leafInList", {"ano", "anoda", "ne", "katoda"}); |
Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 23 | Parser parser(schema); |
| 24 | std::string input; |
| 25 | std::ostringstream errorStream; |
| 26 | |
| 27 | std::set<std::string> expected; |
| 28 | |
| 29 | SECTION("set mod:leafEnum ") |
| 30 | { |
| 31 | input = "set mod:leafEnum "; |
| 32 | expected = {"lala", "lol", "data", "coze"}; |
| 33 | } |
| 34 | |
| 35 | SECTION("set mod:leafEnum c") |
| 36 | { |
| 37 | input = "set mod:leafEnum c"; |
| 38 | expected = {"coze"}; |
| 39 | } |
| 40 | |
| 41 | SECTION("set mod:leafEnum l") |
| 42 | { |
| 43 | input = "set mod:leafEnum l"; |
| 44 | expected = {"lala", "lol"}; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | SECTION("set mod:contA/leafInCont ") |
| 49 | { |
| 50 | input = "set mod:contA/leafInCont "; |
| 51 | expected = {"abc", "def"}; |
| 52 | } |
| 53 | |
| 54 | SECTION("set mod:list[number=42]/leafInList ") |
| 55 | { |
| 56 | input = "set mod:list[number=42]/leafInList "; |
| 57 | expected = {"ano", "anoda", "ne", "katoda"}; |
| 58 | } |
| 59 | |
| 60 | REQUIRE(parser.completeCommand(input, errorStream) == expected); |
| 61 | } |