blob: 21410c8f3134f0b75e72b8e6aa1b58830730b402 [file] [log] [blame]
Václav Kubernát57272422019-02-08 12:48:24 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8
9#include "trompeloeil_catch.h"
10#include "parser.hpp"
11#include "static_schema.hpp"
12
13TEST_CASE("command completion")
14{
15 auto schema = std::make_shared<StaticSchema>();
16 Parser parser(schema);
17 std::string input;
18 std::ostringstream errorStream;
19 std::set<std::string> expected;
20 SECTION("")
21 {
22 input = "";
23 expected = {"cd", "create", "delete", "set", "commit", "get", "ls", "discard"};
24 }
25
26 SECTION(" ")
27 {
28 input = " ";
29 expected = {"cd", "create", "delete", "set", "commit", "get", "ls", "discard"};
30 }
31
32 SECTION("c")
33 {
34 input = "c";
Václav Kubernáta395d332019-02-13 16:49:20 +010035 expected = {"cd", "commit", "create"};
Václav Kubernát57272422019-02-08 12:48:24 +010036 }
37
38 SECTION("d")
39 {
40 input = "d";
Václav Kubernáta395d332019-02-13 16:49:20 +010041 expected = {"delete", "discard"};
Václav Kubernát57272422019-02-08 12:48:24 +010042 }
43
44 SECTION("x")
45 {
46 input = "x";
47 expected = {};
48 }
49
50 SECTION("cd")
51 {
52 input = "cd";
53 // TODO: depending on how Readline works, this will have to be changed to include a space
Václav Kubernáta395d332019-02-13 16:49:20 +010054 expected = {"cd"};
Václav Kubernát57272422019-02-08 12:48:24 +010055 }
56
57 SECTION("create")
58 {
59 input = "create";
Václav Kubernáta395d332019-02-13 16:49:20 +010060 expected = {"create"};
Václav Kubernát57272422019-02-08 12:48:24 +010061 }
62
63 REQUIRE(parser.completeCommand(input, errorStream) == expected);
64}