Václav Kubernát | d666296 | 2018-03-22 17:41:33 +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 | |
Václav Kubernát | 26b5608 | 2020-02-03 18:28:56 +0100 | [diff] [blame] | 9 | #include "trompeloeil_doctest.hpp" |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 10 | #include "ast_commands.hpp" |
Václav Kubernát | 0af7257 | 2020-07-22 15:15:59 +0200 | [diff] [blame^] | 11 | #include "leaf_data_helpers.hpp" |
Václav Kubernát | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 12 | #include "parser.hpp" |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 13 | #include "static_schema.hpp" |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 14 | |
| 15 | TEST_CASE("cd") |
| 16 | { |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 17 | auto schema = std::make_shared<StaticSchema>(); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 18 | schema->addModule("example"); |
| 19 | schema->addModule("second"); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 20 | schema->addContainer("/", "example:a"); |
| 21 | schema->addContainer("/", "second:a"); |
| 22 | schema->addContainer("/", "example:b"); |
| 23 | schema->addContainer("/example:a", "example:a2"); |
| 24 | schema->addContainer("/example:b", "example:b2"); |
| 25 | schema->addContainer("/example:a/example:a2", "example:a3"); |
| 26 | schema->addContainer("/example:b/example:b2", "example:b3"); |
| 27 | schema->addList("/", "example:list", {"number"}); |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 28 | schema->addLeaf("/example:list", "example:number", yang::Int32{}); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 29 | schema->addContainer("/example:list", "example:contInList"); |
| 30 | schema->addList("/", "example:twoKeyList", {"number", "name"}); |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 31 | schema->addLeaf("/example:twoKeyList", "example:number", yang::Int32{}); |
| 32 | schema->addLeaf("/example:twoKeyList", "example:name", yang::String{}); |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 33 | schema->addRpc("/", "example:launch-nukes"); |
Václav Kubernát | 0af7257 | 2020-07-22 15:15:59 +0200 | [diff] [blame^] | 34 | schema->addList("/", "example:ports", {"name"}); |
| 35 | schema->addLeaf("/example:ports", "example:name", createEnum({"A", "B", "C"})); |
Václav Kubernát | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 36 | Parser parser(schema); |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 37 | std::string input; |
Václav Kubernát | 2315c73 | 2018-05-16 20:25:55 +0200 | [diff] [blame] | 38 | std::ostringstream errorStream; |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 39 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 40 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 41 | SECTION("valid input") |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 42 | { |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 43 | cd_ expected; |
| 44 | |
| 45 | SECTION("container") |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 46 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 47 | SECTION("example:a") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 48 | { |
Václav Kubernát | d6fd249 | 2018-11-19 15:11:16 +0100 | [diff] [blame] | 49 | SECTION("trailing slash") |
| 50 | { |
| 51 | input = "cd example:a/"; |
| 52 | expected.m_path.m_trailingSlash = TrailingSlash::Present; |
| 53 | } |
| 54 | SECTION("no trailing slash") |
| 55 | { |
| 56 | input = "cd example:a"; |
| 57 | } |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 58 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 59 | } |
| 60 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 61 | SECTION("second:a") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 62 | { |
Václav Kubernát | d6fd249 | 2018-11-19 15:11:16 +0100 | [diff] [blame] | 63 | SECTION("trailing slash") |
| 64 | { |
| 65 | input = "cd second:a/"; |
| 66 | expected.m_path.m_trailingSlash = TrailingSlash::Present; |
| 67 | } |
| 68 | SECTION("no trailing slash") |
| 69 | { |
| 70 | input = "cd second:a"; |
| 71 | } |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 72 | expected.m_path.m_nodes.emplace_back(module_{"second"}, container_("a")); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 73 | } |
| 74 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 75 | SECTION("example:b") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 76 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 77 | input = "cd example:b"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 78 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("b")); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 79 | } |
| 80 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 81 | SECTION("example:a/a2") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 82 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 83 | input = "cd example:a/a2"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 84 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 85 | expected.m_path.m_nodes.emplace_back(container_("a2")); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | SECTION("example:a/example:a2") |
| 89 | { |
| 90 | input = "cd example:a/example:a2"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 91 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 92 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a2")); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | SECTION("example:b/b2") |
| 96 | { |
| 97 | input = "cd example:b/b2"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 98 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("b")); |
| 99 | expected.m_path.m_nodes.emplace_back(container_("b2")); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 100 | } |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 101 | } |
| 102 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 103 | SECTION("list elements") |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 104 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 105 | SECTION("example:list[number=1]") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 106 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 107 | input = "cd example:list[number=1]"; |
Václav Kubernát | c15fe82 | 2020-06-04 11:28:39 +0200 | [diff] [blame] | 108 | auto keys = ListInstance { |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 109 | {"number", int32_t{1}}}; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 110 | expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("list", keys)); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 111 | } |
| 112 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 113 | SECTION("example:list[number=1]/contInList") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 114 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 115 | input = "cd example:list[number=1]/contInList"; |
Václav Kubernát | c15fe82 | 2020-06-04 11:28:39 +0200 | [diff] [blame] | 116 | auto keys = ListInstance { |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 117 | {"number", int32_t{1}}}; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 118 | expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("list", keys)); |
| 119 | expected.m_path.m_nodes.emplace_back(container_("contInList")); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 120 | } |
| 121 | |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 122 | SECTION("example:twoKeyList[number=4][name='abcd']") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 123 | { |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 124 | input = "cd example:twoKeyList[number=4][name='abcd']"; |
Václav Kubernát | c15fe82 | 2020-06-04 11:28:39 +0200 | [diff] [blame] | 125 | auto keys = ListInstance { |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 126 | {"number", int32_t{4}}, |
| 127 | {"name", std::string{"abcd"}}}; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 128 | expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("twoKeyList", keys)); |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 129 | } |
Václav Kubernát | 0af7257 | 2020-07-22 15:15:59 +0200 | [diff] [blame^] | 130 | |
| 131 | SECTION("enum key type") |
| 132 | { |
| 133 | input = "cd example:ports[name=A]"; |
| 134 | auto keys = ListInstance { |
| 135 | {"name", enum_{"A"}}}; |
| 136 | expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("ports", keys)); |
| 137 | } |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 138 | } |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 139 | |
| 140 | SECTION("whitespace handling") |
| 141 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 142 | SECTION(" cd example:a ") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 143 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 144 | input = " cd example:a "; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 145 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 146 | } |
| 147 | } |
| 148 | |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 149 | SECTION("moving up") |
| 150 | { |
Václav Kubernát | c2bfe49 | 2020-06-15 13:19:07 +0200 | [diff] [blame] | 151 | SECTION("moving up when already in root") |
| 152 | { |
| 153 | input = "cd .."; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 154 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
Václav Kubernát | c2bfe49 | 2020-06-15 13:19:07 +0200 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | SECTION("moving up TWICE when already in root") |
| 158 | { |
| 159 | input = "cd ../.."; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 160 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
| 161 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
Václav Kubernát | c2bfe49 | 2020-06-15 13:19:07 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 164 | SECTION("example:a/..") |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 165 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 166 | input = "cd example:a/.."; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 167 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 168 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 169 | } |
| 170 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 171 | SECTION("example:a/../example:a") |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 172 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 173 | input = "cd example:a/../example:a"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 174 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 175 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
| 176 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 177 | } |
| 178 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 179 | SECTION("example:a/../example:a/a2") |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 180 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 181 | input = "cd example:a/../example:a/a2"; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 182 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 183 | expected.m_path.m_nodes.emplace_back(nodeup_()); |
| 184 | expected.m_path.m_nodes.emplace_back(module_{"example"}, container_("a")); |
| 185 | expected.m_path.m_nodes.emplace_back(container_("a2")); |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 189 | command_ command = parser.parseCommand(input, errorStream); |
| 190 | REQUIRE(command.type() == typeid(cd_)); |
| 191 | REQUIRE(boost::get<cd_>(command) == expected); |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 192 | } |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 193 | SECTION("invalid input") |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 194 | { |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 195 | SECTION("missing space between a command and its arguments") |
| 196 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 197 | SECTION("cdexample:a") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 198 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 199 | input = "cdexample:a"; |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 200 | } |
| 201 | } |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 202 | |
| 203 | SECTION("whitespace between module and nodename") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 204 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 205 | SECTION("cd example: a") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 206 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 207 | input = "cd example: a"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 208 | } |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 209 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 210 | SECTION("cd example : a") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 211 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 212 | input = "cd example : a"; |
| 213 | } |
| 214 | |
| 215 | SECTION("cd example :a") |
| 216 | { |
| 217 | input = "cd example :a"; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | SECTION("entering modules") |
| 222 | { |
| 223 | SECTION("cd example") |
| 224 | { |
| 225 | input = "cd example"; |
| 226 | } |
| 227 | |
| 228 | SECTION("cd example:") |
| 229 | { |
| 230 | input = "cd example:"; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | SECTION("garbage arguments handling") |
| 235 | { |
| 236 | SECTION("cd example:a garbage") |
| 237 | { |
| 238 | input = "cd example:a garbage"; |
| 239 | } |
| 240 | SECTION("cd example:a/a2 garbage") |
| 241 | { |
| 242 | input = "cd example:a/a2 garbage"; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | SECTION("invalid node identifiers") |
| 247 | { |
| 248 | SECTION("example:nonexistent") |
| 249 | { |
| 250 | input = "cd example:nonexistent"; |
| 251 | } |
| 252 | |
| 253 | SECTION("example:nonexistent/lol") |
| 254 | { |
| 255 | input = "cd example:nonexistent/lol"; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | SECTION("invalid module identifiers") |
| 260 | { |
| 261 | SECTION("elpmaxe:nonexistent") |
| 262 | { |
| 263 | input = "cd elpmaxe:nonexistent"; |
| 264 | } |
| 265 | |
| 266 | SECTION("elpmaxe:nonexistent/example:lol") |
| 267 | { |
| 268 | input = "cd elpmaxe:nonexistent/example:lol"; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | SECTION("no top-level module") |
| 273 | { |
| 274 | SECTION("cd a") |
| 275 | { |
| 276 | input = "cd a"; |
| 277 | } |
| 278 | |
| 279 | SECTION("cd example:a/../a") |
| 280 | { |
| 281 | input = "cd example:a/../a"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 282 | } |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 283 | } |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 284 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 285 | SECTION("invalid list key identifiers") |
| 286 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 287 | SECTION("example:list") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 288 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 289 | input = "cd example:list"; |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 292 | SECTION("example:list[]") |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 293 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 294 | input = "cd example:list[]"; |
Václav Kubernát | 7e4e82f | 2018-05-14 20:04:58 +0200 | [diff] [blame] | 295 | } |
| 296 | |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 297 | SECTION("example:twoKeyList[invalidKey='4']") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 298 | { |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 299 | input = "cd example:twoKeyList[invalidKey='4']"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 300 | } |
| 301 | |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 302 | SECTION("example:twoKeyList[number=4][number=5]") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 303 | { |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 304 | input = "cd example:twoKeyList[number=4][number=5]"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 305 | } |
| 306 | |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 307 | SECTION("example:twoKeyList[number=4][name='lol'][number=7]") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 308 | { |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 309 | input = "cd example:twoKeyList[number=4][name='lol'][number=7]"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 310 | } |
| 311 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 312 | SECTION("example:twoKeyList[number=4]") |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 313 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 314 | input = "cd example:twoKeyList[number=4]"; |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 315 | } |
Václav Kubernát | 89728d8 | 2018-09-13 16:28:28 +0200 | [diff] [blame] | 316 | |
| 317 | SECTION("strings must be quoted") |
| 318 | { |
| 319 | input = "cd example:twoKeyList[number=4][name=abcd]"; |
| 320 | } |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 321 | } |
Václav Kubernát | 9fa5dca | 2020-06-01 03:56:41 +0200 | [diff] [blame] | 322 | |
| 323 | SECTION("no space between list prefix and suffix") |
| 324 | { |
| 325 | input = "cd example:list [number=10]"; |
| 326 | } |
| 327 | |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 328 | SECTION("cd into rpc") |
| 329 | { |
| 330 | input = "cd example:launch-nukes"; |
| 331 | } |
| 332 | |
Jan Kundrát | c381e63 | 2019-03-14 13:39:11 +0100 | [diff] [blame] | 333 | REQUIRE_THROWS_AS(parser.parseCommand(input, errorStream), InvalidCommandException); |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 334 | } |
| 335 | } |