LCOV - code coverage report
Current view: top level - irohad/model/converters/impl - json_common.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 19 19 100.0 %
Date: 2019-03-07 14:46:43 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "model/converters/json_common.hpp"
       7             : 
       8             : using namespace rapidjson;
       9             : 
      10             : namespace iroha {
      11             :   namespace model {
      12             :     namespace converters {
      13             :       Value serializeSignature(const Signature &signature,
      14             :                                Document::AllocatorType &allocator) {
      15          15 :         Value document;
      16          15 :         document.SetObject();
      17             : 
      18          15 :         document.AddMember(
      19          15 :             "pubkey", signature.pubkey.to_hexstring(), allocator);
      20          15 :         document.AddMember(
      21          15 :             "signature", signature.signature.to_hexstring(), allocator);
      22             : 
      23          15 :         return document;
      24          15 :       }
      25             : 
      26             :       boost::optional<Document> stringToJson(const std::string &string) {
      27          22 :         Document document;
      28          22 :         document.Parse(string);
      29          22 :         if (document.HasParseError()) {
      30           1 :           return boost::none;
      31             :         }
      32          21 :         return document;
      33          22 :       }
      34             : 
      35             :       std::string jsonToString(const Document &document) {
      36          15 :         StringBuffer sb;
      37          15 :         PrettyWriter<StringBuffer> writer(sb);
      38          15 :         document.Accept(writer);
      39          15 :         return sb.GetString();
      40          15 :       }
      41             :     }  // namespace converters
      42             :   }    // namespace model
      43             : }  // namespace iroha

Generated by: LCOV version 1.13