blob: a8ec4d2eb6e2a5612fadcc10bacbb98786b4eab5 [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
Jan Kundráta33cf082019-03-28 11:55:57 +010010#include "trompeloeil_doctest.h"
Václav Kubernát989b5de2019-02-20 16:28:35 +010011#include "parser.hpp"
12#include "static_schema.hpp"
13
14TEST_CASE("enum completion")
15{
16 auto schema = std::make_shared<StaticSchema>();
17 schema->addModule("mod");
Václav Kubernátefcac932020-01-10 15:26:32 +010018 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át989b5de2019-02-20 16:28:35 +010023 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}