@@ -157,6 +157,89 @@ TEST_CASE("CLI. Base tests", "[cli]") {
157157 REQUIRE (displayed.cursorColumn == 7 );
158158 }
159159
160+ SECTION (" Move cursor to start" ) {
161+ cli.send (" both\x1B [Hget" );
162+ cli.process ();
163+ auto displayed = cli.getDisplay ();
164+ REQUIRE (displayed.lines .size () == 1 );
165+ REQUIRE (displayed.lines [0 ] == " > get both" );
166+ REQUIRE (displayed.cursorColumn == 5 );
167+ }
168+
169+ SECTION (" Move cursor to start with 1~ alternative sequence" ) {
170+ cli.send (" both\x1B [1~get" );
171+ cli.process ();
172+ auto displayed = cli.getDisplay ();
173+ REQUIRE (displayed.lines .size () == 1 );
174+ REQUIRE (displayed.lines [0 ] == " > get both" );
175+ REQUIRE (displayed.cursorColumn == 5 );
176+ }
177+
178+ SECTION (" Move cursor to start with 7~ alternative sequence" ) {
179+ cli.send (" both\x1B [7~get" );
180+ cli.process ();
181+ auto displayed = cli.getDisplay ();
182+ REQUIRE (displayed.lines .size () == 1 );
183+ REQUIRE (displayed.lines [0 ] == " > get both" );
184+ REQUIRE (displayed.cursorColumn == 5 );
185+ }
186+
187+ SECTION (" Move cursor to start then end" ) {
188+ cli.send (" both\x1B [Hget \x1B [F" );
189+ cli.process ();
190+ auto displayed = cli.getDisplay ();
191+ REQUIRE (displayed.lines .size () == 1 );
192+ REQUIRE (displayed.lines [0 ] == " > get both" );
193+ REQUIRE (displayed.cursorColumn == 10 );
194+ }
195+
196+ SECTION (" Move cursor to start then end with 4~ alternative sequence" ) {
197+ cli.send (" both\x1B [Hget \x1B [4~" );
198+ cli.process ();
199+ auto displayed = cli.getDisplay ();
200+ REQUIRE (displayed.lines .size () == 1 );
201+ REQUIRE (displayed.lines [0 ] == " > get both" );
202+ REQUIRE (displayed.cursorColumn == 10 );
203+ }
204+
205+
206+ SECTION (" Move cursor to start then end with 8~ alternative sequence" ) {
207+ cli.send (" both\x1B [Hget \x1B [8~" );
208+ cli.process ();
209+ auto displayed = cli.getDisplay ();
210+ REQUIRE (displayed.lines .size () == 1 );
211+ REQUIRE (displayed.lines [0 ] == " > get both" );
212+ REQUIRE (displayed.cursorColumn == 10 );
213+ }
214+
215+ SECTION (" Move cursor back and perform Delete" ) {
216+ cli.send (" get baoth\x1B [D\x1B [D\x1B [D\x1B\x1B [D\x1B [3~" );
217+ cli.process ();
218+ auto displayed = cli.getDisplay ();
219+ REQUIRE (displayed.lines .size () == 1 );
220+ REQUIRE (displayed.lines [0 ] == " > get both" );
221+ REQUIRE (displayed.cursorColumn == 7 );
222+ }
223+
224+ SECTION (" Delete at end of section" ) {
225+ cli.sendLine (" set example\x1B [3~" );
226+ cli.process ();
227+
228+ auto lines = cli.getDisplay ().lines ;
229+
230+ REQUIRE (lines[0 ] == " > set example" );
231+
232+ }
233+
234+ SECTION (" Delete at start of line should work" ) {
235+ cli.sendLine (" nset\x1B [D\x1B [D\x1B [D\x1B [D\x1B [3~" );
236+ cli.process ();
237+
238+ auto lines = cli.getDisplay ().lines ;
239+
240+ REQUIRE (lines[0 ] == " > set" );
241+ }
242+
160243 SECTION (" Command that is too long" ) {
161244 size_t cmdMax = embeddedCliDefaultConfig ()->cmdBufferSize ;
162245 std::string cmdMaxTest = std::string (cmdMax/2 , ' x' );
0 commit comments