Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame^] | 1 | /* |
| 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 | |
| 13 | TEST_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"; |
| 35 | expected = {"d", "ommit", "reate"}; |
| 36 | } |
| 37 | |
| 38 | SECTION("d") |
| 39 | { |
| 40 | input = "d"; |
| 41 | expected = {"elete", "iscard"}; |
| 42 | } |
| 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 |
| 54 | expected = {""}; |
| 55 | } |
| 56 | |
| 57 | SECTION("create") |
| 58 | { |
| 59 | input = "create"; |
| 60 | expected = {""}; |
| 61 | } |
| 62 | |
| 63 | REQUIRE(parser.completeCommand(input, errorStream) == expected); |
| 64 | } |