<commit_before>#include "minunit.h"
#include <lcthw/ringbuffer.h>

char *test_read_write()
{
    RingBuffer *buffer = RingBuffer_create(100);
    char *data = calloc(1, 100);

    mu_assert(RingBuffer_empty(buffer), "Should be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");

    int rc = RingBuffer_write(buffer, "hello", sizeof("hello"));
    mu_assert(rc == sizeof("hello"), "Failed to write hello.");
    rc = RingBuffer_write(buffer, "Zed", sizeof("Zed"));
    mu_assert(rc == sizeof("Zed"), "Failed to write Zed.");

    mu_assert(!RingBuffer_empty(buffer), "Should NOT be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");

    rc = RingBuffer_read(buffer, data, sizeof("hello"));
    mu_assert(rc == sizeof("hello"), "Failed to read the hello out.");

    mu_assert(!RingBuffer_empty(buffer), "Should be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");
 
    rc = RingBuffer_read(buffer, data, sizeof("Zed"));
    mu_assert(rc == sizeof("Zed"), "Failed to read the Zed out.");
    mu_assert(RingBuffer_empty(buffer), "Should be empty.");

    RingBuffer_destroy(buffer);
    free(data);

    return NULL;
}



char *all_tests() {
    mu_suite_start();

    mu_run_test(test_read_write);

    return NULL;
}

RUN_TESTS(all_tests);
<commit_msg>Cleaned up ringbuffer tests.<commit_after>#include "minunit.h"
#include <lcthw/ringbuffer.h>

static RingBuffer *buffer = NULL;
char data[100] = {'\0'};

char *test_create()
{
    buffer = RingBuffer_create(100);
    mu_assert(buffer != NULL, "Failed to make ringbuffer.");

    return NULL;
}

char *test_destroy()
{
    RingBuffer_destroy(buffer);

    return NULL;
}

char *test_read_write()
{
    mu_assert(RingBuffer_empty(buffer), "Should be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");

    int rc = RingBuffer_write(buffer, "hello", sizeof("hello"));
    mu_assert(rc == sizeof("hello"), "Failed to write hello.");
    rc = RingBuffer_write(buffer, "Zed", sizeof("Zed"));
    mu_assert(rc == sizeof("Zed"), "Failed to write Zed.");

    mu_assert(!RingBuffer_empty(buffer), "Should NOT be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");

    rc = RingBuffer_read(buffer, data, sizeof("hello"));
    mu_assert(rc == sizeof("hello"), "Failed to read the hello out.");

    mu_assert(!RingBuffer_empty(buffer), "Should be empty.");
    mu_assert(!RingBuffer_full(buffer), "Should NOT be full.");
 
    rc = RingBuffer_read(buffer, data, sizeof("Zed"));
    mu_assert(rc == sizeof("Zed"), "Failed to read the Zed out.");
    mu_assert(RingBuffer_empty(buffer), "Should be empty.");

    return NULL;
}



char *all_tests() {
    mu_suite_start();

    mu_run_test(test_create);
    mu_run_test(test_read_write);
    mu_run_test(test_destroy);

    return NULL;
}

RUN_TESTS(all_tests);

{'fraction_non_alphanumeric': 0.15963750435691879, 'fraction_numerical': 0.004879749041477867, 'mean_word_length': 4.529865125240848, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6311206', 'n_tokens_mistral': 982, 'n_tokens_neox': 928, 'n_words': 222}