github.com/jmigpin/editor@v1.6.0/util/iout/iorw/rwundo/edits_test.go (about) 1 package rwundo 2 3 import ( 4 "testing" 5 ) 6 7 func TestEdits1(t *testing.T) { 8 ur := &UndoRedo{Index: 10, D: []byte("0"), I: []byte("12")} 9 edits := &Edits{} 10 edits.Append(ur) 11 12 a, b, ok := edits.preCursor.SelectionIndexesUnsorted() 13 if !(ok == true && a == 10 && b == 11) { 14 t.Fatal() 15 } 16 17 a, b, ok = edits.postCursor.SelectionIndexesUnsorted() 18 if !(ok == true && a == 10 && b == 12) { 19 t.Fatal() 20 } 21 } 22 23 func TestEdits2(t *testing.T) { 24 ur := &UndoRedo{Index: 10, D: []byte(""), I: []byte("12")} 25 edits := &Edits{} 26 edits.Append(ur) 27 28 ok := edits.preCursor.HaveSelection() 29 b := edits.preCursor.Index() 30 if !(ok == false && b == 10) { 31 t.Fatal() 32 } 33 34 a, b, ok := edits.postCursor.SelectionIndexesUnsorted() 35 if !(ok == true && a == 10 && b == 12) { 36 t.Fatal() 37 } 38 } 39 40 func TestEdits3(t *testing.T) { 41 ur := &UndoRedo{Index: 10, D: []byte("0"), I: []byte("")} 42 edits := &Edits{} 43 edits.Append(ur) 44 45 a, b, ok := edits.preCursor.SelectionIndexesUnsorted() 46 _ = a 47 if !(ok == true && b == 11) { 48 t.Fatal() 49 } 50 51 ok = edits.postCursor.HaveSelection() 52 b = edits.postCursor.Index() 53 if !(ok == false && b == 10) { 54 t.Fatal() 55 } 56 }