Showing 2 of 4 files from the diff.
Newly tracked file
src/tests/test_utils.cpp changed.
Other files ignored by Codecov

@@ -758,14 +758,6 @@
Loading
758 758
            {
759 759
            converted = Botan::ucs4_to_utf8(in.data(), in.size());
760 760
            }
761 -
         else if(type == "UTF8-LATIN1")
762 -
            {
763 -
            converted = Botan::utf8_to_latin1(in_str);
764 -
            }
765 -
         else if(type == "UTF16-LATIN1")
766 -
            {
767 -
            converted = Botan::ucs2_to_latin1(in_str);
768 -
            }
769 761
         else if(type == "LATIN1-UTF8")
770 762
            {
771 763
            converted = Botan::latin1_to_utf8(in_str);
@@ -779,73 +771,6 @@
Loading
779 771
780 772
         return result;
781 773
         }
782 -
783 -
      Test::Result utf16_to_latin1_negative_tests()
784 -
         {
785 -
         Test::Result result("Charset negative tests");
786 -
787 -
         result.test_throws("conversion fails for non-Latin1 characters", []()
788 -
            {
789 -
            // "abcdefŸabcdef"
790 -
            std::vector<uint8_t> input = { 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66, 0x01,
791 -
                                           0x78, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66
792 -
                                         };
793 -
794 -
            Botan::ucs2_to_latin1(std::string(input.begin(), input.end()));
795 -
            });
796 -
797 -
         result.test_throws("conversion fails for UTF16 string with odd number of bytes", []()
798 -
            {
799 -
            std::vector<uint8_t> input = { 0x00, 0x61, 0x00 };
800 -
801 -
            Botan::ucs2_to_latin1(std::string(input.begin(), input.end()));
802 -
            });
803 -
804 -
         return result;
805 -
         }
806 -
807 -
      Test::Result utf8_to_latin1_negative_tests()
808 -
         {
809 -
         Test::Result result("Charset negative tests");
810 -
811 -
         result.test_throws("conversion fails for non-Latin1 characters", []()
812 -
            {
813 -
            // "abcdefŸabcdef"
814 -
            const std::vector<uint8_t> input =
815 -
               {
816 -
               0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5,
817 -
               0xB8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
818 -
               };
819 -
820 -
            Botan::utf8_to_latin1(std::string(input.begin(), input.end()));
821 -
            });
822 -
823 -
         result.test_throws("invalid utf-8 string", []()
824 -
            {
825 -
            // sequence truncated
826 -
            const std::vector<uint8_t> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5 };
827 -
            Botan::utf8_to_latin1(std::string(input.begin(), input.end()));
828 -
            });
829 -
830 -
         result.test_throws("invalid utf-8 string", []()
831 -
            {
832 -
            std::vector<uint8_t> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC8, 0xB8, 0x61 };
833 -
            Botan::utf8_to_latin1(std::string(input.begin(), input.end()));
834 -
            });
835 -
836 -
         return result;
837 -
         }
838 -
839 -
      std::vector<Test::Result> run_final_tests() override
840 -
         {
841 -
         Test::Result result("Charset negative tests");
842 -
843 -
         result.merge(utf16_to_latin1_negative_tests());
844 -
         result.merge(utf8_to_latin1_negative_tests());
845 -
846 -
         return{ result };
847 -
         }
848 -
849 774
   };
850 775
851 776
BOTAN_REGISTER_TEST("utils", "charset", Charset_Tests);

@@ -92,66 +92,6 @@
Loading
92 92
   return s;
93 93
   }
94 94
95 -
/*
96 -
* Convert from UTF-8 to ISO 8859-1
97 -
*/
98 -
std::string utf8_to_latin1(const std::string& utf8)
99 -
   {
100 -
   std::string iso8859;
101 -
102 -
   size_t position = 0;
103 -
   while(position != utf8.size())
104 -
      {
105 -
      const uint8_t c1 = static_cast<uint8_t>(utf8[position++]);
106 -
107 -
      if(c1 <= 0x7F)
108 -
         {
109 -
         iso8859 += static_cast<char>(c1);
110 -
         }
111 -
      else if(c1 >= 0xC0 && c1 <= 0xC7)
112 -
         {
113 -
         if(position == utf8.size())
114 -
            throw Decoding_Error("UTF-8: sequence truncated");
115 -
116 -
         const uint8_t c2 = static_cast<uint8_t>(utf8[position++]);
117 -
         const uint8_t iso_char = ((c1 & 0x07) << 6) | (c2 & 0x3F);
118 -
119 -
         if(iso_char <= 0x7F)
120 -
            throw Decoding_Error("UTF-8: sequence longer than needed");
121 -
122 -
         iso8859 += static_cast<char>(iso_char);
123 -
         }
124 -
      else
125 -
         throw Decoding_Error("UTF-8: Unicode chars not in Latin1 used");
126 -
      }
127 -
128 -
   return iso8859;
129 -
   }
130 -
131 -
/*
132 -
* Convert from UCS-2 to ISO 8859-1
133 -
*/
134 -
std::string ucs2_to_latin1(const std::string& ucs2)
135 -
   {
136 -
   if(ucs2.size() % 2 == 1)
137 -
      throw Decoding_Error("UCS-2 string has an odd number of bytes");
138 -
139 -
   std::string latin1;
140 -
141 -
   for(size_t i = 0; i != ucs2.size(); i += 2)
142 -
      {
143 -
      const uint8_t c1 = ucs2[i];
144 -
      const uint8_t c2 = ucs2[i+1];
145 -
146 -
      if(c1 != 0)
147 -
         throw Decoding_Error("UCS-2 has non-Latin1 characters");
148 -
149 -
      latin1 += static_cast<char>(c2);
150 -
      }
151 -
152 -
   return latin1;
153 -
   }
154 -
155 95
/*
156 96
* Convert from ISO 8859-1 to UTF-8
157 97
*/
Files Coverage
src 92.38%
Project Totals (565 files) 92.38%
1
---
2

3
# Documentation
4
# https://github.com/codecov/support/wiki/Codecov-Yaml#full-yaml
5
#
6
# Validate this file
7
# curl --data-binary @codecov.yml https://codecov.io/validate
8

9
coverage:
10
  status:
11
    project:
12
      default:
13
        # Random seeds in tests lead to a +/-0.05% coverage span even for PRs
14
        # that do not change source code
15
        threshold: 0.05
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading