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