⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cxb3005.a

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻 A
📖 第 1 页 / 共 2 页
字号:
              TC_char_array,              TC_size_t_Count,              Append_Nul => True);         Report.Failed("Constraint_Error not raised when the Target " &                       "parameter of Procedure To_C is not long enough " &                       "to hold the converted string");         Report.Comment(char_to_Character(TC_char_array(0)) &                        " printed to defeat optimization");      exception         when Constraint_Error => null;  -- OK, expected exception.         when others           =>            Report.Failed("Incorrect exception raised by Procedure "    &                          "To_C when the Target parameter is not long " &                          "enough to contain the char_array result");      end;      -- Check that the procedure To_Ada converts char elements of the      -- char_array parameter Item to the corresponding character elements      -- of string out parameter Target, with result string length based on      -- the Trim_Nul parameter.      --      -- Case of appended nul char on the char_array In parameter.      TC_char_array := To_C ("ACVC-95", Append_Nul => True); -- 8 total chars.      TC_String     := (others => '*');                      -- Reinitialize.      To_Ada (Item     => TC_char_array,              Target   => TC_String,              Count    => TC_Natural_Count,              Trim_Nul => False);      if TC_Natural_Count /= 8 then         Report.Failed("Incorrect value returned in out parameter Count " &                       "by Procedure To_Ada, case of Trim_Nul => False");      end if;      for i in 1..TC_Natural_Count loop         if Character_to_char(TC_String(i)) /= TC_char_array(size_t(i-1))         then            Report.Failed("Incorrect result from Procedure To_Ada when " &                          "checking individual char values, case of "    &                          "Trim_Nul => False, when a nul is present in " &                          "the char_array input parameter; "             &                          "position = " & Integer'Image(Integer(i)));         end if;      end loop;      if TC_String(TC_Natural_Count) /= Latin_1.Nul then         Report.Failed("Last character of String result of Procedure "     &                       "To_Ada is not Nul, even though a nul was present " &                       "in the char_array argument, and the Trim_Nul "     &                       "parameter was set to False");      end if;      TC_char_array(0..3) := To_C ("XYz", Append_Nul => True); -- 4 chars.      TC_String           := (others => '*');                  -- Reinit.      To_Ada (Item     => TC_char_array,              Target   => TC_String,              Count    => TC_Natural_Count,              Trim_Nul => True);      if TC_Natural_Count /= 3 then         Report.Failed("Incorrect value returned in out parameter Count " &                       "by Procedure To_Ada, case of Trim_Nul => True");      end if;      for i in 1..TC_Natural_Count loop         if Character_to_char(TC_String(i)) /= TC_char_array(size_t(i-1))         then            Report.Failed("Incorrect result from Procedure To_Ada when " &                          "checking individual char values, case of "    &                          "Trim_Nul => True, when a nul is present in "  &                          "the char_array input parameter; "             &                          "position = " & Integer'Image(Integer(i)));         end if;      end loop;      if TC_String(TC_Natural_Count) = Latin_1.Nul then         Report.Failed("Last character of String result of Procedure " &                       "To_Ada is  Nul, even though the Trim_Nul "     &                       "parameter was set to True");      end if;      -- Check that TC_String(TC_Natural_Count+1) is unchanged by procedure      -- To_Ada.      if TC_String(TC_Natural_Count+1) /= '*' then         Report.Failed("Incorrect modification to TC_String at position " &                       Integer'Image(TC_Natural_Count+1) & " expected = " &                       "*, found = " & TC_String(TC_Natural_Count+1));      end if;      -- Case of no nul char being present in the char_array argument.      TC_char_array := To_C ("ABCDWXYZ", Append_Nul => False);      TC_String     := (others => '*');                  -- Reinitialize.      To_Ada (Item     => TC_char_array,              Target   => TC_String,              Count    => TC_Natural_Count,              Trim_Nul => False);      if TC_Natural_Count /= 8 then         Report.Failed("Incorrect value returned in out parameter Count " &                       "by Procedure To_Ada, case of Trim_Nul => False, " &                       "with no nul char present in the parameter Item");      end if;      for i in 1..TC_Natural_Count loop         if Character_to_char(TC_String(i)) /= TC_char_array(size_t(i-1))         then            Report.Failed("Incorrect result from Procedure To_Ada when "  &                          "checking individual char values, case of "     &                          "Trim_Nul => False, when a nul is not present " &                          "in the char_array input parameter; "           &                          "position = " & Integer'Image(Integer(i)));         end if;      end loop;      if TC_String(TC_Natural_Count) = Latin_1.Nul then         Report.Failed("Last character of String result of Procedure " &                       "To_Ada is Nul, even though the nul char was "  &                       "not present in the parameter Item, with the "  &                       "parameter Trim_Nul => False");      end if;      -- Check that the Procedure To_Ada raises Terminator_Error if the      -- parameter Trim_Nul is set to True, but the actual Item parameter      -- does not contain the nul char.      begin         TC_char_array := To_C ("ABCDWXYZ", Append_Nul => False);         TC_String     := (others => '*');         To_Ada(TC_char_array,                TC_String,                Count    => TC_Natural_Count,                Trim_Nul => True);         Report.Failed("Terminator_Error not raised when Item "    &                       "parameter of To_Ada does not contain the " &                       "nul char, but parameter Trim_Nul => True");         Report.Comment(TC_String & " printed to defeat optimization");      exception         when Terminator_Error => null;  -- OK, expected exception.         when others           =>            Report.Failed("Incorrect exception raised by Procedure " &                          "To_Ada when the Item parameter does not " &                          "contain the nul char, but parameter "     &                          "Trim_Nul => True");      end;      -- Check that Constraint_Error is propagated by procedure To_Ada if the      -- length of string parameter Target is not long enough to hold the      -- converted char_array value (plus nul if Trim_Nul is False).      begin         TC_char_array(0..4) := To_C ("ABCD", Append_Nul => True);         To_Ada(TC_char_array(0..4),   -- 4 chars plus nul char.                TC_Short_String,       -- Length of 4.                Count    => TC_Natural_Count,                Trim_Nul => False);         Report.Failed("Constraint_Error not raised when string "     &                       "parameter Target of Procedure To_Ada is not " &                       "long enough to hold the converted chars");         Report.Comment(TC_Short_String & " printed to defeat optimization");      exception         when Constraint_Error => null;  -- OK, expected exception.         when others           =>            Report.Failed("Incorrect exception raised by Procedure " &                          "To_Ada when string parameter Target is "  &                          "not long enough to hold the converted chars");      end;   exception      when The_Error : others =>         Report.Failed ("The following exception was raised in the " &                        "Test_Block: " & Exception_Name(The_Error));   end Test_Block;   Report.Result;end CXB3005;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -