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