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

randombit / botan / 23225340130

18 Mar 2026 01:53AM UTC coverage: 89.677% (-0.001%) from 89.678%
23225340130

push

github

web-flow
Merge pull request #5456 from randombit/jack/clang-tidy-22

Fix various warnings from clang-tidy 22

104438 of 116460 relevant lines covered (89.68%)

11819947.55 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
namespace {
16

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

22
         const std::vector<uint8_t> vec = {0, 1, 2, 3, 4};
1✔
23

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

26
         result.test_str_eq("PEM encoding", pem1, "-----BEGIN BUNNY-----\nAAE\nCAw\nQ=\n-----END BUNNY-----\n");
1✔
27

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

31
         result.test_str_eq("PEM decoding label", label1, "BUNNY");
1✔
32

33
         result.test_throws("PEM decoding unexpected label",
2✔
34
                            "PEM: Label mismatch, wanted 'FLOOFY' got 'BUNNY'",
35
                            [pem1]() { Botan::PEM_Code::decode_check_label(pem1, "FLOOFY"); });
5✔
36

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

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

47
         return {result};
3✔
48
      }
3✔
49
};
50

51
BOTAN_REGISTER_TEST("pubkey", "pem", PEM_Tests);
52

53
}  // namespace
54

55
}  // namespace Botan_Tests
56

57
#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

© 2026 Coveralls, Inc