File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
source/text/implementation Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,17 @@ package body VSS.Implementation.UTF8_Strings is
108108 Success : Boolean with Unreferenced;
109109
110110 begin
111- if From.Index > To.Index then
111+ if Text.Size = 0 then
112+ -- An empty string, all components of `Size` are zeros.
113+
114+ pragma Assert (From.UTF8_Offset = -1 );
115+ pragma Assert (To.UTF8_Offset = -1 );
116+ -- The only possible position of the cursors is before the first
117+ -- charater.
118+
119+ Size := (0 , 0 , 0 );
120+
121+ elsif From.Index > To.Index then
112122 Size := (0 , 0 , 0 );
113123
114124 else
Original file line number Diff line number Diff line change 7474 Test_Support.Assert (SB = " Ada_With_Private_Absent," );
7575 Test_Support.Assert (S = " ," );
7676 end ;
77+
78+ -- vss-text#5
79+ --
80+ -- Check that `Delete` of the slice from last character to last character
81+ -- in the null and an empty string doesn't raise exception.
82+
83+ declare
84+ SN : VSS.Strings.Virtual_String;
85+ SE : VSS.Strings.Virtual_String := " " ;
86+
87+ begin
88+ SN.Delete (SN.At_Last_Character, SN.At_Last_Character);
89+ Test_Support.Assert (SN.Is_Null);
90+ Test_Support.Assert (SN.Is_Empty);
91+ Test_Support.Assert (SN = SN);
92+
93+ SE.Delete (SE.At_Last_Character, SE.At_Last_Character);
94+ Test_Support.Assert (not SE.Is_Null);
95+ Test_Support.Assert (SE.Is_Empty);
96+ Test_Support.Assert (SE = SE);
97+ end ;
7798end Test_Delete ;
You can’t perform that action at this time.
0 commit comments