<commit_before>// File created: 2012-10-07 22:15:25

#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>

#include <mush/space.h>

#include "coords.h"
#include "typenames.h"

#include "util/random.h"
#include "util/tap.h"
#include "util/utf.h"

#define mushcoords                  NAME(mushcoords)
#define mushcoords_add              CAT(mushcoords,_add)
#define mushbounds                  NAME(mushbounds)
#define mushspace                   NAME(mushspace)
#define mushspace_sizeof            CAT(mushspace,_sizeof)
#define mushspace_init              CAT(mushspace,_init)
#define mushspace_free              CAT(mushspace,_free)
#define mushspace_load_string       CAT(mushspace,_load_string)
#define mushspace_load_string_cell  CAT(mushspace,_load_string_cell)
#define mushspace_load_string_utf8  CAT(mushspace,_load_string_utf8)
#define mushspace_load_string_utf16 CAT(mushspace,_load_string_utf16)
#define mushspace_get               CAT(mushspace,_get)
#define mushspace_get_loose_bounds  CAT(mushspace,_get_loose_bounds)
#define mushspace_get_tight_bounds  CAT(mushspace,_get_tight_bounds)
#define mushspace_put               CAT(mushspace,_put)
#define mushspace_copy              CAT(mushspace,_copy)

#define DATA_LEN ((1 << 20) * 21)

static size_t dummy(const void* a, const void* b, size_t c) {
   (void)a; (void)b;
   return c;
}

int main(void) {
   tap_n((4+5)*4 + (3+5)*2 + (2+5));

   init_genrand(time(NULL));
   unsigned char *data = malloc(DATA_LEN);
   random_fill(data, DATA_LEN);

   const size_t codepoints = DATA_LEN * CHAR_BIT / 21;

   mushcoords beg, end;
   random_fill(beg.v, sizeof beg.v);

   void *space_buf = malloc(mushspace_sizeof);
   mushspace *space;

   bool ok;
   int err;
   mushbounds bounds, expected_loose, expected_tight;

   size_t spaces_beg, spaces_end;

   codepoint_reader cp_reader;

#define BOUNDS_CHECK(skip_tight) \
   mushspace_get_loose_bounds(space, &bounds); \
   \
   tap_leqcos(bounds.beg, expected_loose.beg, \
              "get_loose_bounds reports correct beg", \
              "get_loose_bounds reports too large beg"); \
   tap_geqcos(bounds.end, expected_loose.end, \
              "get_loose_bounds reports correct end", \
              "get_loose_bounds reports too small end"); \
   \
   ok = mushspace_get_tight_bounds(space, &bounds); \
   tap_bool(ok, "get_tight_bounds says that the space is nonempty", \
                "get_tight_bounds says that the space is empty"); \
   \
   if (skip_tight) { \
      tap_skip("manually computed tight bounds not available"); \
      tap_skip("manually computed tight bounds not available"); \<commit_msg>tests/basic-binary: don't say "correct" for loose<commit_after>// File created: 2012-10-07 22:15:25

#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>

#include <mush/space.h>

#include "coords.h"
#include "typenames.h"

#include "util/random.h"
#include "util/tap.h"
#include "util/utf.h"

#define mushcoords                  NAME(mushcoords)
#define mushcoords_add              CAT(mushcoords,_add)
#define mushbounds                  NAME(mushbounds)
#define mushspace                   NAME(mushspace)
#define mushspace_sizeof            CAT(mushspace,_sizeof)
#define mushspace_init              CAT(mushspace,_init)
#define mushspace_free              CAT(mushspace,_free)
#define mushspace_load_string       CAT(mushspace,_load_string)
#define mushspace_load_string_cell  CAT(mushspace,_load_string_cell)
#define mushspace_load_string_utf8  CAT(mushspace,_load_string_utf8)
#define mushspace_load_string_utf16 CAT(mushspace,_load_string_utf16)
#define mushspace_get               CAT(mushspace,_get)
#define mushspace_get_loose_bounds  CAT(mushspace,_get_loose_bounds)
#define mushspace_get_tight_bounds  CAT(mushspace,_get_tight_bounds)
#define mushspace_put               CAT(mushspace,_put)
#define mushspace_copy              CAT(mushspace,_copy)

#define DATA_LEN ((1 << 20) * 21)

static size_t dummy(const void* a, const void* b, size_t c) {
   (void)a; (void)b;
   return c;
}

int main(void) {
   tap_n((4+5)*4 + (3+5)*2 + (2+5));

   init_genrand(time(NULL));
   unsigned char *data = malloc(DATA_LEN);
   random_fill(data, DATA_LEN);

   const size_t codepoints = DATA_LEN * CHAR_BIT / 21;

   mushcoords beg, end;
   random_fill(beg.v, sizeof beg.v);

   void *space_buf = malloc(mushspace_sizeof);
   mushspace *space;

   bool ok;
   int err;
   mushbounds bounds, expected_loose, expected_tight;

   size_t spaces_beg, spaces_end;

   codepoint_reader cp_reader;

#define BOUNDS_CHECK(skip_tight) \
   mushspace_get_loose_bounds(space, &bounds); \
   \
   tap_leqcos(bounds.beg, expected_loose.beg, \
              "get_loose_bounds reports appropriate beg", \
              "get_loose_bounds reports too large beg"); \
   tap_geqcos(bounds.end, expected_loose.end, \
              "get_loose_bounds reports appropriate end", \
              "get_loose_bounds reports too small end"); \
   \
   ok = mushspace_get_tight_bounds(space, &bounds); \
   tap_bool(ok, "get_tight_bounds says that the space is nonempty", \
                "get_tight_bounds says that the space is empty"); \
   \
   if (skip_tight) { \
      tap_skip("manually computed tight bounds not available"); \
      tap_skip("manually computed tight bounds not available"); \
{'fraction_non_alphanumeric': 0.10408086858854362, 'fraction_numerical': 0.013103706476974916, 'mean_word_length': 3.4823825503355703, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '739516', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1808, 'n_words': 389}