github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/edit/lastcmd/lastcmd_test.go (about) 1 package lastcmd 2 3 import ( 4 "testing" 5 6 "github.com/u-root/u-root/cmds/core/elvish/edit/eddefs" 7 "github.com/u-root/u-root/cmds/core/elvish/edit/ui" 8 ) 9 10 var ( 11 theLine = "qw search 'foo bar ~y'" 12 theLastCmd = newState(theLine) 13 14 tests = []eddefs.ListingProviderFilterTest{ 15 {"", []eddefs.ListingShown{ 16 {"M-1", ui.Unstyled(theLine)}, 17 {"0", ui.Unstyled("qw")}, 18 {"1", ui.Unstyled("search")}, 19 {"2", ui.Unstyled("'foo bar ~y'")}}}, 20 {"1", []eddefs.ListingShown{{"1", ui.Unstyled("search")}}}, 21 {"-", []eddefs.ListingShown{ 22 {"M-1", ui.Unstyled(theLine)}, 23 {"-3", ui.Unstyled("qw")}, 24 {"-2", ui.Unstyled("search")}, 25 {"-1", ui.Unstyled("'foo bar ~y'")}}}, 26 {"-1", []eddefs.ListingShown{{"-1", ui.Unstyled("'foo bar ~y'")}}}, 27 } 28 ) 29 30 func TestLastCmd(t *testing.T) { 31 if err := eddefs.TestListingProviderFilter("theLastCmd", theLastCmd, tests); err != nil { 32 t.Error(err) 33 } 34 }