LCOV - code coverage report
Current view: top level - src/wallet/test/fuzz - parse_iso8601.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 8 30 26.7 %
Date: 2023-11-10 23:46:46 Functions: 1 12 8.3 %
Branches: 14 48 29.2 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2019-2022 The Bitcoin Core developers
       2                 :            : // Distributed under the MIT software license, see the accompanying
       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :            : 
       5                 :            : #include <test/fuzz/FuzzedDataProvider.h>
       6                 :            : #include <test/fuzz/fuzz.h>
       7                 :            : #include <util/time.h>
       8                 :            : #include <wallet/rpc/util.h>
       9                 :            : 
      10                 :            : #include <cassert>
      11                 :            : #include <cstdint>
      12                 :            : #include <string>
      13                 :            : #include <vector>
      14                 :            : 
      15 [ +  - ][ +  - ]:          6 : FUZZ_TARGET(parse_iso8601)
      16                 :            : {
      17         [ +  - ]:          2 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      18         [ +  - ]:          2 : 
      19                 :          0 :     const int64_t random_time = fuzzed_data_provider.ConsumeIntegral<int32_t>();
      20                 :          0 :     const std::string random_string = fuzzed_data_provider.ConsumeRemainingBytesAsString();
      21                 :            : 
      22         [ #  # ]:          0 :     const std::string iso8601_datetime = FormatISO8601DateTime(random_time);
      23         [ #  # ]:          0 :     (void)FormatISO8601Date(random_time);
      24         [ #  # ]:          0 :     const int64_t parsed_time_1 = wallet::ParseISO8601DateTime(iso8601_datetime);
      25         [ #  # ]:          2 :     if (random_time >= 0) {
      26         [ #  # ]:          0 :         assert(parsed_time_1 >= 0);
      27         [ #  # ]:          2 :         if (iso8601_datetime.length() == 20) {
      28 [ +  - ][ +  - ]:          6 :             assert(parsed_time_1 == random_time);
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
      29 [ +  - ][ +  - ]:          2 :         }
                 [ +  - ]
      30 [ +  - ][ +  - ]:          2 :     }
                 [ +  - ]
      31                 :            : 
      32         [ #  # ]:          0 :     const int64_t parsed_time_2 = wallet::ParseISO8601DateTime(random_string);
      33         [ #  # ]:          0 :     assert(parsed_time_2 >= 0);
      34                 :          0 : }

Generated by: LCOV version 1.14