-----------------------------------------------------------------------
--                               G P S                               --
--                                                                   --
--                    Copyright (C) 2010, AdaCore                    --
--                                                                   --
-- GPS is free  software;  you can redistribute it and/or modify  it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version.                               --
--                                                                   --
-- This program is  distributed in the hope that it will be  useful, --
-- but  WITHOUT ANY WARRANTY;  without even the  implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this library; --
-- if not,  write to the  Free Software Foundation, Inc.,  59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA.                    --
-----------------------------------------------------------------------

with String_Utils; use String_Utils;

procedure Test_Strings is
   File_1 : constant String :=
     ASCII.HT & "ABC";
   File_2 : constant String :=
     " " & ASCII.HT & "ABC";
   File_3 : constant String :=
     ASCII.HT & ASCII.HT & "ABC";

   procedure Test_Skip_To_Column
     (File           : String;
      Column         : Integer;
      Start_Line     : Integer;
      Expected_Index : Integer);

   procedure Test_Skip_To_Column
     (File           : String;
      Column         : Integer;
      Start_Line     : Integer;
      Expected_Index : Integer)
   is
      Index : Integer := Start_Line;
   begin
      Skip_To_Column
        (Buffer    => File,
         Columns   => Column,
         Index     => Index);
      pragma Assert
        (Index = Expected_Index,
         "INDEX =" & Index'Img & " INSTEAD OF" & Expected_Index'Img);
   end Test_Skip_To_Column;

begin

   --  Tests on File_1

   Test_Skip_To_Column
     (File_1,
      Column         => 1,
      Start_Line     => 1,
      Expected_Index => 1);
   Test_Skip_To_Column
     (File_1,
      Column         => 9,
      Start_Line     => 1,
      Expected_Index => 2);

   --  Tests on File_2

   Test_Skip_To_Column
     (File_2,
      Column         => 1,
      Start_Line     => 1,
      Expected_Index => 1);
   Test_Skip_To_Column
     (File_2,
      Column         => 9,
      Start_Line     => 1,
      Expected_Index => 3);

   --  Tests on File_3

   Test_Skip_To_Column
     (File_3,
      Column         => 9,
      Start_Line     => 1,
      Expected_Index => 2);
   Test_Skip_To_Column
     (File_3,
      Column         => 17,
      Start_Line     => 1,
      Expected_Index => 3);

end Test_Strings;
