<commit_before>#include "./lib/snow/snow/snow.h"

#define get_zero_string(A) calloc(1, (A + 1) * sizeof(char))

#include "sstrings.h"

#define setup(name, size) \
    char** name = string_array_new(size, MAX_PROPERTY_LENGTH); \
    defer(string_array_free(name, size))

#define array_length(n) sizeof(n)/sizeof(n[0])

#define test_string "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

describe(vector, {
    it("inits zero string array correctly", {
        char** arr = string_array_new(0, MAX_PROPERTY_LENGTH);

        assertneq(arr, NULL);

        string_array_free(arr, 0);
    });

    it("inits non-zero string array correctly", {
        char** arr = string_array_new(13, MAX_PROPERTY_LENGTH);

        assertneq(arr, NULL);
        for (size_t i = 0; i < 13; i++) {
            assertneq(arr[i], NULL);
        }

        string_array_free(arr, 13);
    });

#if 1
    it("resizes array up from zero correctly", {
        setup(arr, 0);

        assertneq(arr, NULL);

        size_t newlen = 13;
        printf("\nold arr %p\n", arr);
        string_array_resize(&arr, 0, newlen);
        printf("\nnew arr %p\n", arr);

        assertneq(arr, NULL);

        for (size_t i = 0; i < newlen; i++) {
            strncpy(arr[i], test_string, MAX_PROPERTY_LENGTH);
            asserteq(strncmp(arr[i], test_string, MAX_PROPERTY_LENGTH), 0);
            assertneq(arr[i], NULL);
        }
        string_array_free(arr, newlen);
    });
#endif

    it("resizes array up correctly", {
        setup(arr, 3);

        assertneq(arr, NULL);

        size_t newlen = 13;
        printf("\nold arr %p\n", arr);
        string_array_resize(&arr, 3, newlen);
        printf("\nnew arr %p\n", arr);

        assertneq(arr, NULL);

#if 0
        for (size_t i = 0; i < newlen; i++) {
            //strncpy(arr[i], test_string, MAX_PROPERTY_LENGTH);
            //asserteq(strncmp(arr[i], test_string, MAX_PROPERTY_LENGTH), 0);
            assertneq(arr[i], NULL);
        }
#endif
        string_array_free(arr, newlen);
    });
});

snow_main();
<commit_msg>Enable final test<commit_after>#include "./lib/snow/snow/snow.h"

#define get_zero_string(A) calloc(1, (A + 1) * sizeof(char))

#include "sstrings.h"

#define setup(name, size) \
    char** name = string_array_new(size, MAX_PROPERTY_LENGTH); \
    defer(string_array_free(name, size))

#define array_length(n) sizeof(n)/sizeof(n[0])

#define test_string "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

describe(vector, {
    it("inits zero string array correctly", {
        char** arr = string_array_new(0, MAX_PROPERTY_LENGTH);

        assertneq(arr, NULL);

        string_array_free(arr, 0);
    });

    it("inits non-zero string array correctly", {
        char** arr = string_array_new(13, MAX_PROPERTY_LENGTH);

        assertneq(arr, NULL);
        for (size_t i = 0; i < 13; i++) {
            assertneq(arr[i], NULL);
        }

        string_array_free(arr, 13);
    });

#if 1
    it("resizes array up from zero correctly", {
        setup(arr, 0);

        assertneq(arr, NULL);

        size_t newlen = 13;

        string_array_resize(&arr, 0, newlen);

        assertneq(arr, NULL);

        for (size_t i = 0; i < newlen; i++) {
            strncpy(arr[i], test_string, MAX_PROPERTY_LENGTH);
            asserteq(strncmp(arr[i], test_string, MAX_PROPERTY_LENGTH), 0);
            assertneq(arr[i], NULL);
        }
        string_array_free(arr, newlen);
    });
#endif

    it("resizes array up correctly", {
        setup(arr, 3);

        assertneq(arr, NULL);

        size_t newlen = 13;

        string_array_resize(&arr, 3, newlen);

        assertneq(arr, NULL);

#if 1
        for (size_t i = 0; i < newlen; i++) {
            strncpy(arr[i], test_string, MAX_PROPERTY_LENGTH);
            assertneq(arr[i], NULL);
            asserteq(strncmp(arr[i], test_string, MAX_PROPERTY_LENGTH), 0);
        }
#endif
        string_array_free(arr, newlen);
    });
});

snow_main();

{'fraction_non_alphanumeric': 0.09205426356589147, 'fraction_numerical': 0.008397932816537468, 'mean_word_length': 4.62488646684832, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '7429308', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1626, 'n_words': 294}