with Integer_Sets;  use Integer_Sets;

procedure Test_Floor is

   S : Set;
   C : Cursor;
   B : Boolean;

begin

   C := Floor (S, 0);
   pragma Assert (C = No_Element);


   Insert (S, 1, C, B);
   pragma Assert (B);
   pragma Assert (Element (C) = 1);

   C := Floor (S, 0);
   pragma Assert (C = No_Element);

   C := Floor (S, 1);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 1);

   C := Floor (S, 2);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 1);


   Insert (S, 2, C, B);
   pragma Assert (B);
   pragma Assert (Element (C) = 2);

   C := Floor (S, 0);
   pragma Assert (C = No_Element);

   C := Floor (S, 1);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 1);

   C := Floor (S, 2);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 2);

   C := Floor (S, 3);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 2);


   Insert (S, 4, C, B);
   pragma Assert (B);
   pragma Assert (Element (C) = 4);

   C := Floor (S, 0);
   pragma Assert (C = No_Element);

   C := Floor (S, 1);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 1);

   C := Floor (S, 2);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 2);

   C := Floor (S, 3);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 2);

   C := Floor (S, 4);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 4);

   C := Floor (S, 5);
   pragma Assert (Has_Element (C));
   pragma Assert (Element (C) = 4);

end Test_Floor;


