• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/src/tests/test_pem.cpp
1
/*
2
* (C) 2017 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_PEM_CODEC)
10

11
   #include <botan/pem.h>
12

13
namespace Botan_Tests {
14

15
class PEM_Tests : public Test {
1✔
16
   public:
17
      std::vector<Test::Result> run() override {
1✔
18
         Test::Result result("PEM encoding");
1✔
19

20
         std::vector<uint8_t> vec = {0, 1, 2, 3, 4};
1✔
21

22
         const std::string pem1 = Botan::PEM_Code::encode(vec, "BUNNY", 3);
1✔
23

24
         result.test_eq("PEM encoding", pem1, "-----BEGIN BUNNY-----\nAAE\nCAw\nQ=\n-----END BUNNY-----\n");
2✔
25

26
         std::string label1 = "this is overwritten";
1✔
27
         const Botan::secure_vector<uint8_t> decoded1 = Botan::PEM_Code::decode(pem1, label1);
1✔
28

29
         result.test_eq("PEM decoding label", label1, "BUNNY");
2✔
30

31
         result.test_throws("PEM decoding unexpected label",
4✔
32
                            "PEM: Label mismatch, wanted 'FLOOFY' got 'BUNNY'",
33
                            [pem1]() { Botan::PEM_Code::decode_check_label(pem1, "FLOOFY"); });
8✔
34

35
         const std::string malformed_pem1 = "---BEGIN BUNNY-----\n-----END BUNNY-----";
1✔
36
         result.test_throws("PEM decoding bad init label", "PEM: No PEM header found", [malformed_pem1]() {
11✔
37
            Botan::PEM_Code::decode_check_label(malformed_pem1, "BUNNY");
1✔
38
         });
×
39

40
         const std::string malformed_pem2 = "-----BEGIN BUNNY-----\n-----END FLOOFY-----";
1✔
41
         result.test_throws("PEM decoding bad init label", "PEM: Malformed PEM trailer", [malformed_pem2]() {
11✔
42
            Botan::PEM_Code::decode_check_label(malformed_pem2, "BUNNY");
1✔
43
         });
×
44

45
         return {result};
3✔
46
      }
6✔
47
};
48

49
BOTAN_REGISTER_TEST("pubkey", "pem", PEM_Tests);
50

51
}
52

53
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc