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