<commit_before>/* vi: set ts=4 expandtab shiftwidth=4: */
/**
 * @file
 * @copyright Copyright 2015-2020 Digital Aggregates Corporation, Colorado, USA.
 * @note Licensed under the terms in LICENSE.txt.
 * @brief This is a unit test of the Buffer feature.
 * @author <NAME> <mailto:<EMAIL>>
 * @see Diminuto <https://github.com/coverclock/com-diag-diminuto>
 * @details
 * This is a unit test of the Buffer feature.
 */

#include "com/diag/diminuto/diminuto_unittest.h"
#include "com/diag/diminuto/diminuto_log.h"
#include "com/diag/diminuto/diminuto_buffer.h"
#include "com/diag/diminuto/diminuto_countof.h"
#include "com/diag/diminuto/diminuto_heap.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "../src/diminuto_buffer.h"

static int memverify(void * s, int c, size_t n)
{
    unsigned char * p;
    unsigned char ch;
    for (p = (unsigned char *)s, ch = c; n > 0; --n, ++p) {
        if (*p != ch) {
            return 0;
        }
    }
    return !0;
}

int main(int argc, char * argv[])
{
    int debug;

    SETLOGMASK();

    debug = (argc > 1);

    {
        size_t count;
        size_t item;

        TEST();

        ASSERT((count = diminuto_buffer_count()) == 10);
        for (item = 0; item < count; ++item) {
            ASSERT(diminuto_buffer_size(item) == (1 << (item + 3)));
        }
        for (item = 0; item < count; ++item) {
            ASSERT(diminuto_buffer_isempty(item));
        }

        STATUS();
    }

    {
        size_t count;
        ssize_t overhead;
        size_t requested;
        size_t actual;
        size_t expected;
        size_t effective;
        size_t item;
        size_t hash;<commit_msg>[1] Added more unit tests to Buffer unit test suite.<commit_after>/* vi: set ts=4 expandtab shiftwidth=4: */
/**
 * @file
 * @copyright Copyright 2015-2020 Digital Aggregates Corporation, Colorado, USA.
 * @note Licensed under the terms in LICENSE.txt.
 * @brief This is a unit test of the Buffer feature.
 * @author <NAME> <mailto:<EMAIL>>
 * @see Diminuto <https://github.com/coverclock/com-diag-diminuto>
 * @details
 * This is a unit test of the Buffer feature.
 */

#include "com/diag/diminuto/diminuto_unittest.h"
#include "com/diag/diminuto/diminuto_log.h"
#include "com/diag/diminuto/diminuto_buffer.h"
#include "com/diag/diminuto/diminuto_countof.h"
#include "com/diag/diminuto/diminuto_heap.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "../src/diminuto_buffer.h"

static int memverify(void * s, int c, size_t n)
{
    unsigned char * p;
    unsigned char ch;
    for (p = (unsigned char *)s, ch = c; n > 0; --n, ++p) {
        if (*p != ch) {
            return 0;
        }
    }
    return !0;
}

int main(int argc, char * argv[])
{
    int debug;

    SETLOGMASK();

    debug = (argc > 1);

    {
        volatile uint8_t unused;
        diminuto_buffer_t overhead;

        ASSERT(sizeof(overhead) == 8);
        ASSERT(sizeof(overhead.header.item) == sizeof(overhead.header.next));
        ASSERT((((uintptr_t)(&overhead)) & 0x7) == 0);
    }

    {
        size_t count;
        size_t item;

        TEST();

        ASSERT((count = diminuto_buffer_count()) == 10);
        for (item = 0; item < count; ++item) {
            ASSERT(diminuto_buffer_size(item) == (1 << (item + 3)));
        }
        for (item = 0; item < count; ++item) {
            ASSERT(diminuto_buffer_isempty(item));
        }

        STATUS();
    }

    {
        size_t count;
        ssize_t overhead;
        size_t requested;
        size_t actual;
        size_t expected;
        size_t effective;
        size_t item;
        size_t hash;
{'fraction_non_alphanumeric': 0.1397139713971397, 'fraction_numerical': 0.012651265126512651, 'mean_word_length': 2.415023474178404, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '4096880', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1248, 'n_words': 322}