| 442 | } |
| 443 | |
| 444 | int |
| 445 | main(int argc, const char** argv) |
| 446 | { |
| 447 | if( argc != 2 ) |
| 448 | { |
| 449 | std::cerr << "Usage: cbor FILE_NAME\n"; |
| 450 | return EXIT_FAILURE; |
| 451 | } |
| 452 | |
| 453 | std::ifstream is(argv[1]); |
| 454 | is.exceptions(std::ios::badbit); |
| 455 | |
| 456 | const value jv = parse(is); |
| 457 | |
| 458 | std::vector<unsigned char> out; |
| 459 | serialize_cbor_value( jv, out ); |
| 460 | |
| 461 | value jv2; |
| 462 | parse_cbor_value( out.data(), out.data() + out.size(), jv2 ); |
| 463 | |
| 464 | if( jv != jv2 ) |
| 465 | { |
| 466 | std::cerr << "Roundtrip check failed\n"; |
| 467 | return EXIT_FAILURE; |
| 468 | } |
| 469 | |
| 470 | return EXIT_SUCCESS; |
| 471 | } |
| 472 | |
| 473 | // end::example_cbor[] |
nothing calls this directly
no test coverage detected