randombit / botan
Showing 1 of 1 files from the diff.

@@ -16,6 +16,41 @@
Loading
16 16
17 17
#if defined(BOTAN_HAS_ASN1)
18 18
19 +
Test::Result test_OID_to_string()
20 +
   {
21 +
   /*
22 +
   See #2730 and #2237
23 +
24 +
   Certain locales format integers with thousands seperators.  This
25 +
   caused a subtle bug which caused OID comparisons to fail because
26 +
   OID::to_string(), which used ostringstream, introduced a thousands
27 +
   seperator when the OID component had a value >= 1000. But this
28 +
   only failed in certain locales (pt_BR was reported).
29 +
30 +
   Nominally C++ requires std::to_string to also be locale-respecting.
31 +
   But, libc++, libstdc++, and MSVC's STL library all implement
32 +
   std::to_string in a way that ignores locales, because adding locale
33 +
   support means std::to_string will be both slow and a serialization
34 +
   point. So as a stopgap we assume this behavior from std::to_string.
35 +
36 +
   Here we test the original issue of #2237 to verify it works. If
37 +
   the compiler implements std::to_string in a way that respects locale,
38 +
   *and* this test is run in a locale that uses thousands seperators,
39 +
   then it will fail. Which is much better than a very subtle failure.
40 +
   However if it ever does fail then we must replace nearly every
41 +
   call to std::to_string with something else that ignores locale.
42 +
   */
43 +
44 +
   Botan::OID oid{1,2,1000,1001,1002000};
45 +
46 +
   Test::Result result("OID::to_string");
47 +
48 +
   result.test_eq("OID::to_string behaves as we expect",
49 +
                  oid.to_string(), "1.2.1000.1001.1002000");
50 +
51 +
   return result;
52 +
   }
53 +
19 54
Test::Result test_add_have_OID()
20 55
   {
21 56
   Test::Result result("OID add");
@@ -83,6 +118,7 @@
Loading
83 118
84 119
         std::vector<std::function<Test::Result()>> fns =
85 120
            {
121 +
            test_OID_to_string,
86 122
            test_add_have_OID,
87 123
            test_add_have_OID_str,
88 124
            test_add_and_lookup,
Files Coverage
src 92.38%
Project Totals (567 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