blob: e352c7f63a89178c204195446ae6c6ee63f30216 [file] [log] [blame]
Václav Kubernát989b5de2019-02-20 16:28:35 +01001
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
10#include "trompeloeil_catch.h"
11#include "ast_commands.hpp"
12#include "parser.hpp"
13#include "static_schema.hpp"
14
15TEST_CASE("enum completion")
16{
17 auto schema = std::make_shared<StaticSchema>();
18 schema->addModule("mod");
19 schema->addContainer("", "mod:contA");
20 schema->addLeafEnum("", "mod:leafEnum", {"lala", "lol", "data", "coze"});
21 schema->addLeafEnum("mod:contA", "mod:leafInCont", {"abc", "def"});
22 schema->addList("", "mod:list", {"number"});
23 schema->addLeafEnum("mod:list", "mod:leafInList", {"ano", "anoda", "ne", "katoda"});
24 Parser parser(schema);
25 std::string input;
26 std::ostringstream errorStream;
27
28 std::set<std::string> expected;
29
30 SECTION("set mod:leafEnum ")
31 {
32 input = "set mod:leafEnum ";
33 expected = {"lala", "lol", "data", "coze"};
34 }
35
36 SECTION("set mod:leafEnum c")
37 {
38 input = "set mod:leafEnum c";
39 expected = {"coze"};
40 }
41
42 SECTION("set mod:leafEnum l")
43 {
44 input = "set mod:leafEnum l";
45 expected = {"lala", "lol"};
46 }
47
48
49 SECTION("set mod:contA/leafInCont ")
50 {
51 input = "set mod:contA/leafInCont ";
52 expected = {"abc", "def"};
53 }
54
55 SECTION("set mod:list[number=42]/leafInList ")
56 {
57 input = "set mod:list[number=42]/leafInList ";
58 expected = {"ano", "anoda", "ne", "katoda"};
59 }
60
61 REQUIRE(parser.completeCommand(input, errorStream) == expected);
62}