Skip to content

Commit

Permalink
Merge branch 'revert-f872af2b' into 'master'
Browse files Browse the repository at this point in the history
Revert "Merge branch 'revert-6703ac0e' into 'master'"

See merge request eng/ide/VSS!346
  • Loading branch information
godunko committed Nov 19, 2024
2 parents f872af2 + 48098b3 commit 66cd996
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ check_text:
.objs/tests/test_string_hash
.objs/tests/test_string_insert
.objs/tests/test_string_buffer
.objs/tests/test_string_slice
.objs/tests/test_string_split
.objs/tests/test_string_split_lines
.objs/tests/test_string
Expand Down
1 change: 0 additions & 1 deletion gnat/tests/vss_text_tests.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ project VSS_Text_Tests is
"test_string_hash",
"test_string_insert",
"test_string_buffer",
"test_string_slice",
"test_string_split",
"test_string_split_lines",
"test_string_template",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Dynamic is
return;
end if;

Unchecked_Forward (Self.Pointer.Storage, After);
if To.Index <= Self.Length then
Unchecked_Forward (Self.Pointer.Storage, After);
end if;

Size := After.UTF8_Offset - From.UTF8_Offset;
Length := After.Index - From.Index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Static is
return;
end if;

Unchecked_Forward (Self.Storage, After);
if To.Index <= Self.Length then
Unchecked_Forward (Self.Storage, After);
end if;

Size := After.UTF8_Offset - From.UTF8_Offset;
Length := After.Index - From.Index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright (C) 2021-2022, AdaCore
-- Copyright (C) 2021-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
Expand All @@ -14,9 +14,8 @@
with VSS.Strings.Character_Iterators;
with VSS.Strings.Line_Iterators;

with Test_Support;

procedure Test_String_Slice is
separate (Test_String)
procedure Test_Slice is
use type VSS.Strings.Virtual_String;

S : constant VSS.Strings.Virtual_String :=
Expand Down Expand Up @@ -157,4 +156,33 @@ begin
R := S1.Slice (JLV, JLV);
Test_Support.Assert (R.Is_Null);
end;
end Test_String_Slice;

-- Slice of string with last marker pointing to end of string.
--
-- It was reported under eng/ide/VSS#256

declare
use type VSS.Strings.Character_Count;

SS : VSS.Strings.Virtual_String := "body ";
-- Static storage
SR : VSS.Strings.Virtual_String := "package body ";
-- Reported case: static storage of max size on 64bit platform
SD : VSS.Strings.Virtual_String := "package body Name ";
-- Dynamic storage
R : VSS.Strings.Virtual_String;

begin
R := SS.Slice (SS.At_First_Character, SS.After_Last_Character);
Test_Support.Assert (R.Character_Length = SS.Character_Length);
Test_Support.Assert (R = SS);

R := SR.Slice (SR.At_First_Character, SR.After_Last_Character);
Test_Support.Assert (R.Character_Length = SR.Character_Length);
Test_Support.Assert (R = SR);

R := SD.Slice (SD.At_First_Character, SD.After_Last_Character);
Test_Support.Assert (R.Character_Length = SD.Character_Length);
Test_Support.Assert (R = SD);
end;
end Test_Slice;
9 changes: 9 additions & 0 deletions testsuite/text/test_string.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
--

with VSS.Strings.Character_Iterators;
with VSS.Strings.Line_Iterators;
with VSS.String_Vectors;

with Test_Support;
Expand All @@ -21,6 +22,7 @@ procedure Test_String is
procedure Test_Prepend;
procedure Test_Put_Image;
procedure Test_Replace;
procedure Test_Slice;
procedure Test_Tail;

procedure Test_V705_011;
Expand Down Expand Up @@ -154,6 +156,12 @@ procedure Test_String is
end;
end Test_Replace;

----------------
-- Test_Slice --
----------------

procedure Test_Slice is separate;

---------------
-- Test_Tail --
---------------
Expand Down Expand Up @@ -229,6 +237,7 @@ procedure Test_String is
Test_Support.Run_Testcase (Test_Prepend'Access, "Prepend");
Test_Support.Run_Testcase (Test_Put_Image'Access, "Put_Image");
Test_Support.Run_Testcase (Test_Replace'Access, "Replace");
Test_Support.Run_Testcase (Test_Slice'Access, "Slice");
Test_Support.Run_Testcase (Test_Tail'Access, "Tail");

Test_Support.Run_Testcase (Test_V705_011'Access, "V705_011 TN");
Expand Down

0 comments on commit 66cd996

Please sign in to comment.