@@ -35,9 +35,10 @@ def cmd2_app():
3535 return c
3636
3737
38- # List of strings used with basic, flag, and index based completion functions
38+ # List of strings used with completion functions
3939food_item_strs = ['Pizza' , 'Hamburger' , 'Ham' , 'Potato' , 'Space Food' ]
4040sport_item_strs = ['Bat' , 'Basket' , 'Basketball' , 'Football' ]
41+ delimited_strs = ['/home/user/file.txt' , '/home/user/prog.c' , '/home/otheruser/maps' ]
4142
4243# Dictionary used with flag based completion functions
4344flag_dict = \
@@ -410,6 +411,20 @@ def test_basic_completion_nomatch(cmd2_app):
410411
411412 assert cmd2_app .basic_complete (text , line , begidx , endidx , food_item_strs ) == []
412413
414+ def test_delimiter_completion (cmd2_app ):
415+ text = '/home/'
416+ line = 'load {}' .format (text )
417+ endidx = len (line )
418+ begidx = endidx - len (text )
419+
420+ cmd2_app .delimiter_complete (text , line , begidx , endidx , delimited_strs , '/' )
421+
422+ # Remove duplicates from display_matches and sort it. This is typically done in the display function.
423+ display_set = set (cmd2_app .display_matches )
424+ display_list = list (display_set )
425+ display_list .sort ()
426+
427+ assert display_list == ['otheruser' , 'user' ]
413428
414429def test_flag_based_completion_single (cmd2_app ):
415430 text = 'Pi'
0 commit comments