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

randombit / botan / 11087146043

28 Sep 2024 09:28PM UTC coverage: 92.003% (+0.7%) from 91.274%
11087146043

push

github

web-flow
Create terraform.yml

82959 of 90170 relevant lines covered (92.0%)

9376319.11 hits per line

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

90.91
/src/lib/math/bigint/big_io.cpp
1
/*
2
* BigInt Input/Output
3
* (C) 1999-2007 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/bigint.h>
9
#include <istream>
10
#include <ostream>
11

12
namespace Botan {
13

14
/*
15
* Write the BigInt into a stream
16
*/
17
std::ostream& operator<<(std::ostream& stream, const BigInt& n) {
59✔
18
   const auto stream_flags = stream.flags();
59✔
19
   if(stream_flags & std::ios::oct) {
59✔
20
      throw Invalid_Argument("Octal output of BigInt not supported");
1✔
21
   }
22

23
   const size_t base = (stream_flags & std::ios::hex) ? 16 : 10;
58✔
24

25
   std::string enc;
58✔
26

27
   if(base == 10) {
58✔
28
      enc = n.to_dec_string();
28✔
29
   } else {
30
      enc = n.to_hex_string();
30✔
31
   }
32

33
   stream.write(enc.data(), enc.size());
58✔
34

35
   if(!stream.good()) {
58✔
36
      throw Stream_IO_Error("BigInt output operator has failed");
×
37
   }
38
   return stream;
58✔
39
}
58✔
40

41
/*
42
* Read the BigInt from a stream
43
*/
44
std::istream& operator>>(std::istream& stream, BigInt& n) {
5✔
45
   std::string str;
5✔
46
   std::getline(stream, str);
5✔
47
   if(stream.bad() || (stream.fail() && !stream.eof())) {
5✔
48
      throw Stream_IO_Error("BigInt input operator has failed");
×
49
   }
50
   n = BigInt(str);
5✔
51
   return stream;
5✔
52
}
5✔
53

54
}  // namespace Botan
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