Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +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 | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 10 | #include "datastoreaccess_mock.hpp" |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 11 | #include "parser.hpp" |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 12 | #include "pretty_printers.hpp" |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 13 | #include "static_schema.hpp" |
| 14 | |
| 15 | TEST_CASE("path_completion") |
| 16 | { |
| 17 | auto schema = std::make_shared<StaticSchema>(); |
| 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:ano"); |
| 21 | schema->addContainer("/", "example:anoda"); |
| 22 | schema->addList("/example:ano", "example:listInCont", {"number"}); |
| 23 | schema->addContainer("/", "second:amelie"); |
| 24 | schema->addContainer("/", "example:bota"); |
| 25 | schema->addContainer("/example:ano", "example:a2"); |
| 26 | schema->addContainer("/example:bota", "example:b2"); |
| 27 | schema->addContainer("/example:ano/example:a2", "example:a3"); |
| 28 | schema->addContainer("/example:bota/example:b2", "example:b3"); |
| 29 | schema->addList("/", "example:list", {"number"}); |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 30 | schema->addLeaf("/example:list", "example:number", yang::LeafDataTypes::Int32); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 31 | schema->addContainer("/example:list", "example:contInList"); |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 32 | schema->addList("/", "example:ovoce", {"name"}); |
| 33 | schema->addLeaf("/example:ovoce", "example:name", yang::LeafDataTypes::String); |
| 34 | schema->addList("/", "example:ovocezelenina", {"name"}); |
| 35 | schema->addLeaf("/example:ovocezelenina", "example:name", yang::LeafDataTypes::String); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 36 | schema->addList("/", "example:twoKeyList", {"number", "name"}); |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 37 | schema->addLeaf("/example:twoKeyList", "example:name", yang::LeafDataTypes::String); |
| 38 | schema->addLeaf("/example:twoKeyList", "example:number", yang::LeafDataTypes::Int32); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 39 | schema->addLeaf("/", "example:leafInt", yang::LeafDataTypes::Int32); |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 40 | auto mockDatastore = std::make_shared<MockDatastoreAccess>(); |
| 41 | |
| 42 | // The parser will use DataQuery for key value completion, but I'm not testing that here, so I don't return anything. |
| 43 | ALLOW_CALL(*mockDatastore, listInstances("/example:list")) |
| 44 | .RETURN(std::vector<ListInstance>{}); |
| 45 | ALLOW_CALL(*mockDatastore, listInstances("/example:twoKeyList")) |
| 46 | .RETURN(std::vector<ListInstance>{}); |
| 47 | |
| 48 | // DataQuery gets the schema from DatastoreAccess once |
| 49 | auto expectation = NAMED_REQUIRE_CALL(*mockDatastore, schema()) |
| 50 | .RETURN(schema); |
| 51 | auto dataQuery = std::make_shared<DataQuery>(*mockDatastore); |
| 52 | expectation.reset(); |
| 53 | Parser parser(schema, dataQuery); |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 54 | std::string input; |
| 55 | std::ostringstream errorStream; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 56 | |
| 57 | std::set<std::string> expectedCompletions; |
| 58 | // GCC complains here with -Wmaybe-uninitialized if I don't assign |
| 59 | // something here. I suspect it's because of nested SECTIONs. -1 is an |
| 60 | // invalid value (as in, I'll never expect expectedContextLength to be -1), |
| 61 | // so let's go with that. |
| 62 | int expectedContextLength = -1; |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 63 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 64 | SECTION("node name completion") |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 65 | { |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 66 | SECTION("ls ") |
| 67 | { |
| 68 | input = "ls "; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 69 | expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList", "second:amelie/"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 70 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | SECTION("ls e") |
| 74 | { |
| 75 | input = "ls e"; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 76 | expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 77 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | SECTION("ls example:ano") |
| 81 | { |
| 82 | input = "ls example:ano"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 83 | expectedCompletions = {"example:ano/", "example:anoda/"}; |
| 84 | expectedContextLength = 11; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | SECTION("ls example:ano/example:a") |
| 88 | { |
| 89 | input = "ls example:ano/example:a"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 90 | expectedCompletions = {"example:a2/"}; |
| 91 | expectedContextLength = 9; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | SECTION("ls x") |
| 95 | { |
| 96 | input = "ls x"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 97 | expectedCompletions = {}; |
| 98 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | SECTION("ls /") |
| 102 | { |
| 103 | input = "ls /"; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 104 | expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList", "second:amelie/"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 105 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | SECTION("ls /e") |
| 109 | { |
| 110 | input = "ls /e"; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 111 | expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 112 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 113 | } |
| 114 | |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 115 | SECTION("ls example:bota") |
| 116 | { |
| 117 | input = "ls example:bota"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 118 | expectedCompletions = {"example:bota/"}; |
| 119 | expectedContextLength = 12; |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | SECTION("ls /example:bota") |
| 123 | { |
| 124 | input = "ls /example:bota"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 125 | expectedCompletions = {"example:bota/"}; |
| 126 | expectedContextLength = 12; |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 127 | } |
| 128 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 129 | SECTION("ls /s") |
| 130 | { |
| 131 | input = "ls /s"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 132 | expectedCompletions = {"second:amelie/"}; |
| 133 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 134 | } |
| 135 | |
Václav Kubernát | 26be33a | 2020-02-13 13:30:14 +0100 | [diff] [blame] | 136 | SECTION("ls /example:list/") |
| 137 | { |
| 138 | input = "ls /example:list/"; |
| 139 | expectedCompletions = {"example:contInList/", "example:number "}; |
| 140 | expectedContextLength = 0; |
| 141 | } |
| 142 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 143 | SECTION("ls /example:list[number=3]/") |
| 144 | { |
| 145 | input = "ls /example:list[number=3]/"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 146 | expectedCompletions = {"example:contInList/", "example:number "}; |
| 147 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | SECTION("ls /example:list[number=3]/c") |
| 151 | { |
| 152 | input = "ls /example:list[number=3]/e"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 153 | expectedCompletions = {"example:contInList/", "example:number "}; |
| 154 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | SECTION("ls /example:list[number=3]/a") |
| 158 | { |
| 159 | input = "ls /example:list[number=3]/a"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 160 | expectedCompletions = {}; |
| 161 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 162 | } |
Václav Kubernát | 26be33a | 2020-02-13 13:30:14 +0100 | [diff] [blame] | 163 | |
| 164 | SECTION("ls /example:list/example:contInList/") |
| 165 | { |
| 166 | input = "ls /example:list/example:contInList/"; |
| 167 | expectedCompletions = {}; |
| 168 | expectedContextLength = 0; |
| 169 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 172 | SECTION("list keys completion") |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 173 | { |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 174 | SECTION("cd example:lis") |
| 175 | { |
| 176 | input = "cd example:lis"; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 177 | expectedCompletions = {"example:list"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 178 | expectedContextLength = 11; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 179 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 180 | |
Václav Kubernát | 51853b2 | 2019-04-16 21:53:44 +0200 | [diff] [blame] | 181 | SECTION("set example:list") |
| 182 | { |
| 183 | input = "set example:list"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 184 | expectedCompletions = {"example:list["}; |
| 185 | expectedContextLength = 12; |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | SECTION("cd example:list") |
| 189 | { |
| 190 | input = "cd example:list"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 191 | expectedCompletions = {"example:list["}; |
| 192 | expectedContextLength = 12; |
Václav Kubernát | 51853b2 | 2019-04-16 21:53:44 +0200 | [diff] [blame] | 193 | } |
| 194 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 195 | SECTION("cd example:list[") |
| 196 | { |
| 197 | input = "cd example:list["; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 198 | expectedCompletions = {"number="}; |
| 199 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 200 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 201 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 202 | SECTION("cd example:list[numb") |
| 203 | { |
| 204 | input = "cd example:list[numb"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 205 | expectedCompletions = {"number="}; |
| 206 | expectedContextLength = 4; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 207 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 208 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 209 | SECTION("cd example:list[number") |
| 210 | { |
| 211 | input = "cd example:list[number"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 212 | expectedCompletions = {"number="}; |
| 213 | expectedContextLength = 6; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 214 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 215 | |
Václav Kubernát | 117f7b5 | 2020-01-23 16:10:55 +0100 | [diff] [blame] | 216 | SECTION("cd example:list[number=") |
| 217 | { |
| 218 | input = "cd example:list[number="; |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 219 | expectedCompletions = {}; |
| 220 | expectedContextLength = 0; |
Václav Kubernát | 117f7b5 | 2020-01-23 16:10:55 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 223 | SECTION("cd example:list[number=12") |
| 224 | { |
| 225 | input = "cd example:list[number=12"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 226 | expectedCompletions = {"]/"}; |
| 227 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 228 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 229 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 230 | SECTION("cd example:list[number=12]") |
| 231 | { |
| 232 | input = "cd example:list[number=12]"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 233 | expectedCompletions = {"]/"}; |
| 234 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 235 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 236 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 237 | SECTION("cd example:twoKeyList[") |
| 238 | { |
| 239 | input = "cd example:twoKeyList["; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 240 | expectedCompletions = {"name=", "number="}; |
| 241 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 242 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 243 | |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 244 | SECTION("cd example:twoKeyList[name=\"AHOJ\"") |
| 245 | { |
| 246 | input = "cd example:twoKeyList[name=\"AHOJ\""; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 247 | expectedCompletions = {"]["}; |
| 248 | expectedContextLength = 0; |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | SECTION("cd example:twoKeyList[name=\"AHOJ\"]") |
| 252 | { |
| 253 | input = "cd example:twoKeyList[name=\"AHOJ\"]"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 254 | expectedCompletions = {"]["}; |
| 255 | expectedContextLength = 1; |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 258 | SECTION("cd example:twoKeyList[name=\"AHOJ\"][") |
| 259 | { |
| 260 | input = "cd example:twoKeyList[name=\"AHOJ\"]["; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 261 | expectedCompletions = {"number="}; |
| 262 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 263 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 264 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 265 | SECTION("cd example:twoKeyList[number=42][") |
| 266 | { |
| 267 | input = "cd example:twoKeyList[number=42]["; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 268 | expectedCompletions = {"name="}; |
| 269 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 270 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 271 | |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 272 | SECTION("cd example:twoKeyList[name=\"AHOJ\"][number=123") |
| 273 | { |
| 274 | input = "cd example:twoKeyList[name=\"AHOJ\"][number=123"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 275 | expectedCompletions = {"]/"}; |
| 276 | expectedContextLength = 0; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | SECTION("cd example:twoKeyList[name=\"AHOJ\"][number=123]") |
| 280 | { |
| 281 | input = "cd example:twoKeyList[name=\"AHOJ\"][number=123]"; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 282 | expectedCompletions = {"]/"}; |
| 283 | expectedContextLength = 1; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 284 | } |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 285 | |
| 286 | SECTION("cd example:ovoce") |
| 287 | { |
| 288 | input = "cd example:ovoce"; |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 289 | expectedCompletions = {"example:ovoce", "example:ovocezelenina"}; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 290 | expectedContextLength = 13; |
Václav Kubernát | 4c32548 | 2019-04-11 17:51:55 +0200 | [diff] [blame] | 291 | } |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 292 | |
| 293 | SECTION("cd example:ovoceze") |
| 294 | { |
| 295 | input = "cd example:ovoceze"; |
| 296 | expectedCompletions = {"example:ovocezelenina"}; |
| 297 | expectedContextLength = 15; |
| 298 | } |
| 299 | |
| 300 | SECTION("cd example:ovocezelenina") |
| 301 | { |
| 302 | input = "cd example:ovocezelenina"; |
| 303 | expectedCompletions = {"example:ovocezelenina["}; |
| 304 | expectedContextLength = 21; |
| 305 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 306 | } |
| 307 | |
Václav Kubernát | 8028f94 | 2019-09-25 16:03:23 +0200 | [diff] [blame] | 308 | SECTION("clear completions when no longer inputting path") |
| 309 | { |
| 310 | input = "set example:leafInt "; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 311 | expectedCompletions = {}; |
| 312 | expectedContextLength = 0; |
Václav Kubernát | 8028f94 | 2019-09-25 16:03:23 +0200 | [diff] [blame] | 313 | } |
| 314 | |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 315 | REQUIRE(parser.completeCommand(input, errorStream) == (Completions{expectedCompletions, expectedContextLength})); |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 316 | } |