LCOV - code coverage report
Current view: top level - ers/test/apps - ers_schema_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 28 0
Test Date: 2026-03-29 15:29:34 Functions: 0.0 % 10 0

            Line data    Source code
       1              : #include "ers/Schema.hpp"
       2              : #include <google/protobuf/util/json_util.h>
       3              : 
       4              : #include <boost/asio/ip/host_name.hpp>
       5              : 
       6              : #include <chrono>
       7              : #include <cstdlib>
       8              : #include <iostream>
       9              : #include <string>
      10              : 
      11              : using namespace std;
      12              : using namespace google::protobuf::util;
      13              : 
      14              : using namespace dunedaq::ersschema;
      15              : 
      16              : #include "ers/ers.hpp"
      17              : 
      18            0 : ERS_DECLARE_ISSUE(ersschema, TestIssue, "this is issue with ID: " << id, ((int)id))
      19              : 
      20              : int
      21            0 : main(int, char*[])
      22              : {
      23              : 
      24            0 :   GOOGLE_PROTOBUF_VERIFY_VERSION;
      25              : 
      26            0 :   ersschema::TestIssue first(ERS_HERE, 0);
      27            0 :   ersschema::TestIssue second(ERS_HERE, 1, first);
      28            0 :   ersschema::TestIssue third(ERS_HERE, 2, second);
      29              : 
      30            0 :   dunedaq::ersschema::IssueChain schema;
      31            0 :   to_schema(third, schema);
      32            0 :   schema.set_session("None");
      33            0 :   schema.set_application("ers_schema_test");
      34              : 
      35            0 :   JsonPrintOptions opt;
      36            0 :   opt.add_whitespace = true;
      37            0 :   opt.preserve_proto_field_names = true;
      38              : 
      39            0 :   string json;
      40            0 :   auto status = MessageToJsonString(schema, &json, opt);
      41            0 :   if (!status.ok()) {
      42            0 :     std::cerr << "MessageToJsonString returned error\n";
      43              :     return (1);
      44              :   }
      45            0 :   cout << json << endl;
      46              : 
      47              :   // google::protobuf::Timestamp time;
      48              :   // time.set_seconds( chrono::system_clock::now().time_since_epoch().count() );
      49              :   // (*issue.mutable_time())=time;
      50              : 
      51            0 :   string serial;
      52              : 
      53            0 :   schema.SerializeToString(&serial);
      54              : 
      55            0 :   IssueChain reco;
      56            0 :   reco.ParseFromString(serial.c_str());
      57              : 
      58            0 :   if (schema.final().severity() == reco.final().severity()) {
      59            0 :     cout << "success" << endl;
      60              :   } else {
      61            0 :     cout << "failure" << endl;
      62              :   }
      63              : 
      64              :   // JsonStringToMessage( json, & reco_issue);
      65              : 
      66              :   // if ( issue.name() == reco_issue.name() ) {
      67              :   //   cout << "json success" << endl ;
      68              :   // } else {
      69              :   //   cout << "Jons failure" << endl;
      70              :   // }
      71              : 
      72            0 :   google::protobuf::ShutdownProtobufLibrary();
      73              : 
      74            0 :   return 0;
      75            0 : }
        

Generated by: LCOV version 2.0-1