@@ -31,7 +31,6 @@ SOFTWARE.
3131#include " json.hpp"
3232using nlohmann::json;
3333
34- #include < set>
3534#include < fstream>
3635
3736TEST_CASE (" CBOR" )
@@ -740,13 +739,13 @@ TEST_CASE("CBOR")
740739 {
741740 SECTION (" no byte follows" )
742741 {
743- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf9 })), json::parse_error);
742+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf9 })), json::parse_error& );
744743 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0xf9 })),
745744 " [json.exception.parse_error.110] parse error at 2: unexpected end of input" );
746745 }
747746 SECTION (" only one byte follows" )
748747 {
749- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf9 , 0x7c })), json::parse_error);
748+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf9 , 0x7c })), json::parse_error& );
750749 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0xf9 , 0x7c })),
751750 " [json.exception.parse_error.110] parse error at 3: unexpected end of input" );
752751 }
@@ -1227,28 +1226,28 @@ TEST_CASE("CBOR")
12271226 {
12281227 SECTION (" empty byte vector" )
12291228 {
1230- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >()), json::parse_error);
1229+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >()), json::parse_error& );
12311230 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >()),
12321231 " [json.exception.parse_error.110] parse error at 1: unexpected end of input" );
12331232 }
12341233
12351234 SECTION (" too short byte vector" )
12361235 {
1237- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x18 })), json::parse_error);
1238- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x19 })), json::parse_error);
1239- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x19 , 0x00 })), json::parse_error);
1240- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a })), json::parse_error);
1241- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 })), json::parse_error);
1242- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 , 0x00 })), json::parse_error);
1243- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 , 0x00 , 0x00 })), json::parse_error);
1244- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b })), json::parse_error);
1245- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 })), json::parse_error);
1246- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 })), json::parse_error);
1247- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 })), json::parse_error);
1248- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error);
1249- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error);
1250- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error);
1251- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error);
1236+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x18 })), json::parse_error& );
1237+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x19 })), json::parse_error& );
1238+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x19 , 0x00 })), json::parse_error& );
1239+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a })), json::parse_error& );
1240+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 })), json::parse_error& );
1241+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 , 0x00 })), json::parse_error& );
1242+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1a , 0x00 , 0x00 , 0x00 })), json::parse_error& );
1243+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b })), json::parse_error& );
1244+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 })), json::parse_error& );
1245+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 })), json::parse_error& );
1246+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 })), json::parse_error& );
1247+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error& );
1248+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error& );
1249+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error& );
1250+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 })), json::parse_error& );
12521251
12531252 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0x18 })),
12541253 " [json.exception.parse_error.110] parse error at 2: unexpected end of input" );
@@ -1286,10 +1285,10 @@ TEST_CASE("CBOR")
12861285 {
12871286 SECTION (" concrete examples" )
12881287 {
1289- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1c })), json::parse_error);
1288+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0x1c })), json::parse_error& );
12901289 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0x1c })),
12911290 " [json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0x1C" );
1292- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf8 })), json::parse_error);
1291+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xf8 })), json::parse_error& );
12931292 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0xf8 })),
12941293 " [json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0xF8" );
12951294 }
@@ -1340,14 +1339,14 @@ TEST_CASE("CBOR")
13401339 0xf8
13411340 })
13421341 {
1343- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({static_cast <uint8_t >(byte)})), json::parse_error);
1342+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({static_cast <uint8_t >(byte)})), json::parse_error& );
13441343 }
13451344 }
13461345 }
13471346
13481347 SECTION (" invalid string in map" )
13491348 {
1350- CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xa1 , 0xff , 0x01 })), json::parse_error);
1349+ CHECK_THROWS_AS (json::from_cbor (std::vector<uint8_t >({0xa1 , 0xff , 0x01 })), json::parse_error& );
13511350 CHECK_THROWS_WITH (json::from_cbor (std::vector<uint8_t >({0xa1 , 0xff , 0x01 })),
13521351 " [json.exception.parse_error.113] parse error at 2: expected a CBOR string; last byte: 0xFF" );
13531352 }
@@ -1363,7 +1362,7 @@ TEST_CASE("CBOR")
13631362
13641363 SECTION (" strict mode" )
13651364 {
1366- CHECK_THROWS_AS (json::from_cbor (vec), json::parse_error);
1365+ CHECK_THROWS_AS (json::from_cbor (vec), json::parse_error& );
13671366 CHECK_THROWS_WITH (json::from_cbor (vec),
13681367 " [json.exception.parse_error.110] parse error at 2: expected end of input" );
13691368 }
0 commit comments