<commit_before>
#include <deque>
#include <iterator>
#include <list>
#include <vector>
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#include "iguana/json_reader.hpp"
#include "test_headers.h"
#include <iguana/json.hpp>
#include <iguana/json_util.hpp>
#include <iostream>

TEST_CASE("test parse item num_t") {
  {
    std::string str{"1.4806532964699196e-22"};
    double p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 1.4806532964699196e-22);
  }
  {
    std::string str{""};
    double p{};
    CHECK_THROWS(iguana::parse_item(p, str.begin(), str.end()));
  }
  {
    std::string str{"1.0"};
    int p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 1);
  }
  {
    std::string str{"3000000"};
    long long p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 3000000);
  }
  {
    std::string str;
    str.append(300, '1');
    int p{};
    CHECK_THROWS(iguana::parse_item(p, str.begin(), str.end()));
  }
  {
    std::list<char> arr{'[', '0', '.', '9', ']'};
    std::vector<double> test;
    iguana::from_json(test, arr);
    CHECK(test[0] == 0.9);

    std::deque<char> arr1{'[', '0', '.', '9', ']'};
    iguana::from_json(test, arr1);
    CHECK(test[0] == 0.9);
  }
  {
    std::list<char> arr{'0', '.', '9'};
    for (int i = 0; i < 999; i++) {
      arr.push_back('1');
    }

    double test = 0;
    CHECK_THROWS(iguana::parse_item(test, arr.begin(), arr.end()));
  }
}

TEST_CASE("test parse item array_t") {
  {
    std::string str{"[1, -222]"};
    std::array<int, 2> test;
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test[0] == 1);
    CHECK(test[1] == -222);
  }
  {
    std::string str{"[1, -222,"};
    std::array<int, 2> test;
    CHECK_NOTHROW(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[   "};
    std::array<int, 2> test;
    CHECK_THROWS(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[ ]  "};
    std::array<int, 2> test;
    CHECK_NOTHROW(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[ 1.2345]  "};
    std::array<int, 2> test;
    CHECK_THROWS(iguana::parse_item(test, str.begin(), str.end()));
  }
}

TEST_CASE("test parse item str_t") {
  {
    std::string str{"\"aaaaaaaaaa1\""};
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == str.substr(1, test.size()));
  }
  {
    // this case throw at json_util@line 132
    std::string str{"\"aaa1\""};
    std::string test{};
    // iguana::parse_item(test, str.begin(), str.end());
    // CHECK(test == str.substr(1, test.size()));
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('\\');
    str.push_back('a');
    str.push_back('\"');
    str.push_back('a');
    str.push_back('a');
    str.push_back('1');
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    
    auto begin = str.begin();
    std::advance(begin, 2);
    CHECK(test == "a");
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('a');
    str.push_back('a');
    str.push_back('a');
    str.push_back('1');
    std::string test{};
    test.resize(3);
    iguana::parse_item(test, str.begin(), str.end());
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('\\');
    str.push_back('a');
    str.push_back('\"');
    std::string test{};
    test.resize(1);
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == "a");
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('a');
    str.push_back('\\');
    str.push_back('\"');
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    // CHECK(test == "a");
  }
  {
    std::string str{"\"\\aaaa1\""};
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == str.substr(2, test.size()));
  }
  {
    std::string str{"\"aaaa1\""};<commit_msg>open bug UT<commit_after>
#include <deque>
#include <iterator>
#include <list>
#include <vector>
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#include "iguana/json_reader.hpp"
#include "test_headers.h"
#include <iguana/json.hpp>
#include <iguana/json_util.hpp>
#include <iostream>

TEST_CASE("test parse item num_t") {
  {
    std::string str{"1.4806532964699196e-22"};
    double p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 1.4806532964699196e-22);
  }
  {
    std::string str{""};
    double p{};
    CHECK_THROWS(iguana::parse_item(p, str.begin(), str.end()));
  }
  {
    std::string str{"1.0"};
    int p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 1);
  }
  {
    std::string str{"3000000"};
    long long p{};
    iguana::parse_item(p, str.begin(), str.end());
    CHECK(p == 3000000);
  }
  {
    std::string str;
    str.append(300, '1');
    int p{};
    CHECK_THROWS(iguana::parse_item(p, str.begin(), str.end()));
  }
  {
    std::list<char> arr{'[', '0', '.', '9', ']'};
    std::vector<double> test;
    iguana::from_json(test, arr);
    CHECK(test[0] == 0.9);

    std::deque<char> arr1{'[', '0', '.', '9', ']'};
    iguana::from_json(test, arr1);
    CHECK(test[0] == 0.9);
  }
  {
    std::list<char> arr{'0', '.', '9'};
    for (int i = 0; i < 999; i++) {
      arr.push_back('1');
    }

    double test = 0;
    CHECK_THROWS(iguana::parse_item(test, arr.begin(), arr.end()));
  }
}

TEST_CASE("test parse item array_t") {
  {
    std::string str{"[1, -222]"};
    std::array<int, 2> test;
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test[0] == 1);
    CHECK(test[1] == -222);
  }
  {
    std::string str{"[1, -222,"};
    std::array<int, 2> test;
    CHECK_NOTHROW(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[   "};
    std::array<int, 2> test;
    CHECK_THROWS(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[ ]  "};
    std::array<int, 2> test;
    CHECK_NOTHROW(iguana::parse_item(test, str.begin(), str.end()));
  }
  {
    std::string str{"[ 1.2345]  "};
    std::array<int, 2> test;
    CHECK_THROWS(iguana::parse_item(test, str.begin(), str.end()));
  }
}

TEST_CASE("test parse item str_t") {
  {
    std::string str{"\"aaaaaaaaaa1\""};
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == str.substr(1, test.size()));
  }
  {
    // this case throw at json_util@line 132
    std::string str{"\"aaa1\""};
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == str.substr(1, test.size()));
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('\\');
    str.push_back('a');
    str.push_back('\"');
    str.push_back('a');
    str.push_back('a');
    str.push_back('1');
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    
    auto begin = str.begin();
    std::advance(begin, 2);
    CHECK(test == "a");
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('a');
    str.push_back('a');
    str.push_back('a');
    str.push_back('1');
    std::string test{};
    test.resize(3);
    iguana::parse_item(test, str.begin(), str.end());
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('\\');
    str.push_back('a');
    str.push_back('\"');
    std::string test{};
    test.resize(1);
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == "a");
  }
  {
    std::list<char> str;
    str.push_back('\"');
    str.push_back('a');
    str.push_back('\\');
    str.push_back('\"');
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == "a");
  }
  {
    std::string str{"\"\\aaaa1\""};
    std::string test{};
    iguana::parse_item(test, str.begin(), str.end());
    CHECK(test == str.substr(2, test.size()));
  }
  {
    std::string str{"\"aaaa1\""};
{'fraction_non_alphanumeric': 0.23915503583553377, 'fraction_numerical': 0.029674336728278638, 'mean_word_length': 3.168763102725367, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1413020', 'n_tokens_mistral': 3310, 'n_tokens_neox': 3126, 'n_words': 521}