cxb30061.am

来自「xml大全 可读写调用率很高 xml大全 可读写调用率很高」· AM 代码 · 共 405 行 · 第 1/2 页

AM
405 行
字号
                       "wchar_t input");      end if;      for Code in int range         int(Report.Ident_Int(20)) .. int(Report.Ident_Int(29)) loop            -- 'k' .. 't'         if To_Ada(Item => Char_Gen(Code)) /=	    To_Wide_Character(Character'Val (Character'Pos('k') + (Code - 20)))         then            Report.Failed("Incorrect result from To_Ada with lower case " &                          "alphabetic wchar_t input");         end if;      end loop;      for Code in int range         int(Report.Ident_Int(10)) .. int(Report.Ident_Int(19)) loop            -- 'A' .. 'J'         if To_Ada(Item => Char_Gen(Code)) /=	    To_Wide_Character(Character'Val (Character'Pos('A') + (Code - 10)))         then            Report.Failed("Incorrect result from To_Ada with upper case " &                          "alphabetic wchar_t input");         end if;      end loop;      for Code in int range         int(Report.Ident_Int(0)) .. int(Report.Ident_Int(9)) loop            -- '0' .. '9'         if To_Ada(Item => Char_Gen(Code)) /=	    To_Wide_Character(Character'Val (Character'Pos('0') + (Code)))         then            Report.Failed("Incorrect result from To_Ada with digit " &                          "wchar_t input");         end if;      end loop;      if To_Ada(Item => Char_Gen(30)) /= ' ' then         Report.Failed("Incorrect result from To_Ada with space " &                       "char input");      end if;      if To_Ada(Item => Char_Gen(31)) /= '.' then         Report.Failed("Incorrect result from To_Ada with dot " &                       "char input");      end if;      if To_Ada(Item => Char_Gen(32)) /= ',' then         Report.Failed("Incorrect result from To_Ada with comma " &                       "char input");      end if;      -- Check that the function Is_Nul_Terminated produces correct results      -- whether or not the wchar_array argument contains the      -- Ada.Interfaces.C.wide_nul character.      TC_Wide_String := "abcdefgh";      if Is_Nul_Terminated(Item => To_C(TC_Wide_String, Append_Nul => False))      then         Report.Failed("Incorrect result from Is_Nul_Terminated when no " &                       "wide_nul wchar_t is present");      end if;      if not Is_Nul_Terminated(To_C(TC_Wide_String, Append_Nul => True)) then         Report.Failed("Incorrect result from Is_Nul_Terminated when the " &                       "wide_nul wchar_t is present");      end if;      -- Now that we've tested the character/char versions of To_Ada and To_C,      -- use them to test the string versions.      declare         i                    : size_t  := 0;         j                    : integer := 1;         Incorrect_Conversion : Boolean := False;         TC_No_wide_nul       : constant wchar_array := To_C(TC_Wide_String,                                                             False);         TC_wide_nul_Appended : constant wchar_array := To_C(TC_Wide_String,                                                             True);      begin         -- Check that the function To_C produces a wchar_array result with         -- lower bound of 0, and length dependent upon the Item and         -- Append_Nul parameters (if Append_Nul is True, length is         -- Item'Length + 1; if False, length is Item'Length).         if TC_No_wide_nul'First /= 0 or TC_wide_nul_Appended'First /= 0 then            Report.Failed("Incorrect lower bound from Function To_C");         end if;         if TC_No_wide_nul'Length /= TC_Wide_String'Length then            Report.Failed("Incorrect length returned from Function To_C " &                          "when Append_Nul => False");         end if;         if TC_wide_nul_Appended'Length /= TC_Wide_String'Length + 1 then            Report.Failed("Incorrect length returned from Function To_C " &                          "when Append_Nul => True");         end if;         if not Is_Nul_Terminated(TC_wide_nul_Appended) then            Report.Failed("No wide_nul appended to the wide_string "    &                          "parameter during conversion to wchar_array " &                          "by function To_C");         end if;         for TC_char in Report.Ident_Char('a')..Report.Ident_Char('h') loop            if TC_No_wide_nul(i)       /= To_C(To_Wide_Character(TC_char)) or               TC_wide_nul_Appended(i) /= To_C(To_Wide_Character(TC_char)) then               -- Use single character To_C.               Incorrect_Conversion := True;            end if;            i := i + 1;         end loop;         if Incorrect_Conversion then            Report.Failed("Incorrect result from To_C with wide_string input " &                          "and wchar_array result");         end if;         -- Check that the function To_Ada produces a wide_string result with         -- lower bound of 1, and length dependent upon the Item and         -- Trim_Nul parameters (if Trim_Nul is False, length is Item'Length;         -- if False, length will be the length of the slice of Item prior to         -- the first wide_nul).         declare            TC_No_NUL_Wide_String       : constant Wide_String :=              To_Ada(Item => TC_wide_nul_Appended, Trim_Nul => True);            TC_NUL_Appended_Wide_String : constant Wide_String :=              To_Ada(TC_wide_nul_Appended, False);         begin            if TC_No_NUL_Wide_String'First       /= 1 or               TC_NUL_Appended_Wide_String'First /= 1            then               Report.Failed("Incorrect lower bound from Function To_Ada");            end if;            if TC_No_NUL_Wide_String'Length /= TC_Wide_String'Length then               Report.Failed("Incorrect length returned from Function " &                             "To_Ada when Trim_Nul => True");            end if;            if TC_NUL_Appended_Wide_String'Length /=               TC_Wide_String'Length + 1            then               Report.Failed("Incorrect length returned from Function " &                             "To_Ada when Trim_Nul => False");            end if;            for TC_Character in Wide_Character'('a') .. Wide_Character'('h') loop               if TC_No_NUL_Wide_String(j)       /= TC_Character or                  TC_NUL_Appended_Wide_String(j) /= TC_Character               then                  Report.Failed("Incorrect result from To_Ada with " &                                "char_array input, index = "         &                                Integer'Image(j));               end if;               j := j + 1;            end loop;         end;         -- Check that the function To_Ada raises Terminator_Error if the         -- parameter Trim_Nul is set to True, but the actual Item parameter         -- does not contain the wide_nul wchar_t.         begin            TC_Wide_String := To_Ada(TC_No_wide_nul, Trim_Nul => True);            Report.Failed("Terminator_Error not raised when Item "    &                          "parameter of To_Ada does not contain the " &                          "wide_nul wchar_t, but parameter Trim_Nul " &                          "=> True");            Report.Comment              (To_String(TC_Wide_String) & " printed to defeat optimization");         exception            when Terminator_Error => null;  -- OK, expected exception.            when others           =>               Report.Failed("Incorrect exception raised by function "  &                             "To_Ada when the Item parameter does not " &                             "contain the wide_nul wchar_t, but "       &                             "parameter Trim_Nul => True");         end;      end;   exception      when The_Error : others =>         Report.Failed           ("The following exception was raised in the Test_Block: " &            Ada.Exceptions.Exception_Name(The_Error));   end Test_Block;   Report.Result;end CXB30061;

⌨️ 快捷键说明

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