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

randombit / botan / 11844561993

14 Nov 2024 07:58PM UTC coverage: 91.178% (+0.1%) from 91.072%
11844561993

Pull #4435

github

web-flow
Merge 81dcb29da into e430f157a
Pull Request #4435: Test duration values ​​are now presented in seconds with six digits of precision. Tests without time measurements have been edited.

91856 of 100744 relevant lines covered (91.18%)

9311006.71 hits per line

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

91.3
/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
         result.start_timer();
1✔
20

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

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

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

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

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

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

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

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

46
         result.end_timer();
1✔
47
         return {result};
3✔
48
      }
4✔
49
};
50

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

53
}  // namespace Botan_Tests
54

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