<commit_before>#include <mettle.hpp>
using namespace mettle;

#include "bencode.hpp"

struct at_eof : matcher_tag {
  bool operator ()(const std::string &) const {
    return true;
  }

  template<typename Char, typename Traits>
  bool operator ()(const std::basic_ios<Char, Traits> &ss) const {
    return ss.eof();
  }

  std::string desc() const {
    return "at eof";
  }
};

suite<> test_decode("test decoder", [](auto &_) {

  using BENCODE_ANY_NS::any_cast;

  subsuite<std::string, std::istringstream>(_, "decoding", [](auto &_) {
    using Fixture = fixture_type_t<decltype(_)>;

    _.test("integer", [](auto &) {
      Fixture pos("i666e");
      auto pos_value = bencode::decode(pos);
      expect(pos, at_eof());
      expect(any_cast<bencode::integer>(pos_value), equal_to(666));

      Fixture neg("i-666e");
      auto neg_value = bencode::decode(neg);
      expect(neg, at_eof());
      expect(any_cast<bencode::integer>(neg_value), equal_to(-666));
    });

    _.test("string", [](auto &) {
      Fixture data("4:spam");
      auto value = bencode::decode(data);
      expect(data, at_eof());
      expect(any_cast<bencode::string>(value), equal_to("spam"));
    });

    _.test("list", [](auto &) {
      Fixture data("li666ee");
      auto value = bencode::decode(data);
      auto list = any_cast<bencode::list>(value);
      expect(data, at_eof());
      expect(any_cast<bencode::integer>(list[0]), equal_to(666));
    });

    _.test("dict", [](auto &) {
      Fixture data("d4:spami666ee");
      auto value = bencode::decode(data);<commit_msg>Use the new type-only suite fixtures<commit_after>#include <mettle.hpp>
using namespace mettle;

#include "bencode.hpp"

struct at_eof : matcher_tag {
  bool operator ()(const std::string &) const {
    return true;
  }

  template<typename Char, typename Traits>
  bool operator ()(const std::basic_ios<Char, Traits> &ss) const {
    return ss.eof();
  }

  std::string desc() const {
    return "at eof";
  }
};

suite<> test_decode("test decoder", [](auto &_) {

  using BENCODE_ANY_NS::any_cast;

  subsuite<std::string, std::istringstream>(_, "decoding", type_only,
                                            [](auto &_) {
    using Fixture = fixture_type_t<decltype(_)>;

    _.test("integer", []() {
      Fixture pos("i666e");
      auto pos_value = bencode::decode(pos);
      expect(pos, at_eof());
      expect(any_cast<bencode::integer>(pos_value), equal_to(666));

      Fixture neg("i-666e");
      auto neg_value = bencode::decode(neg);
      expect(neg, at_eof());
      expect(any_cast<bencode::integer>(neg_value), equal_to(-666));
    });

    _.test("string", []() {
      Fixture data("4:spam");
      auto value = bencode::decode(data);
      expect(data, at_eof());
      expect(any_cast<bencode::string>(value), equal_to("spam"));
    });

    _.test("list", []() {
      Fixture data("li666ee");
      auto value = bencode::decode(data);
      auto list = any_cast<bencode::list>(value);
      expect(data, at_eof());
      expect(any_cast<bencode::integer>(list[0]), equal_to(666));
    });

    _.test("dict", []() {
      Fixture data("d4:spami666ee");
      auto value = bencode::decode(data);
{'fraction_non_alphanumeric': 0.18045112781954886, 'fraction_numerical': 0.015037593984962405, 'mean_word_length': 3.5226628895184136, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1509087', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1086, 'n_words': 203}