<commit_before>#include <string>
#include <cassert>

#include <rapidcheck.h>

#include "encode.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
  rc::check("decode_inverts_encode",
            [](const std::string &s0) { assert(s0 == decode(encode(s0))); }, Data, Size);
  return 0;
}<commit_msg>Result printed on failure found is not correct.<commit_after>#include <string>
#include <cassert>
#include <numeric>

#include <rapidcheck.h>

#include "encode.h"

template<typename T>
void print(const std::vector<T> v, std::ostream &o) {
  for (const auto &x : v) {
    o << ", " << x;
  }
  o << std::endl;
}


template<typename T>
T sum_good(const std::vector<T> &v) {
  return std::accumulate(v.begin(), v.end(), static_cast<T>(0));
}


template<typename T>
T sum_bad(const std::vector<T> &v) {
  if (v.size() > 2 && v[0] == 'm') {
    print(v, std::cout);
    return 3;
  }
  
  return sum_good(v);
}




extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
//   rc::check("decode_inverts_encode",
//             [](const std::string &s0) { assert(s0 == decode(encode(s0))); }, Data, Size);


  /// This shows that the output on failure that rapidcheck produces is completely incorrect on failure. Most certainly related to my changes.
  if (!rc::check("Output on Failure is Bogus",
            [](const std::vector<char> &v) { return sum_good(v) == sum_bad(v); }, Data, Size)) {
    assert(false);
  }

  return 0;
}
{'fraction_non_alphanumeric': 0.17302452316076294, 'fraction_numerical': 0.009536784741144414, 'mean_word_length': 3.996598639455782, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5652538', 'n_tokens_mistral': 544, 'n_tokens_neox': 526, 'n_words': 141}