<commit_before>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
#pragma once

#include <assert.h>
#include <float.h>
#include <inttypes.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

struct unit
{
    char const *name;
    void (*run)();
};

struct unit_suite
{
    char const *name;
    int total;
    int num_ok;
    int num_failed;
    struct unit *units[];
};

extern jmp_buf __unit_err;

inline static int run_unit(struct unit_suite *suite, struct unit *u)
{
    if (u == NULL) return 1;

    printf("  [TEST] %s ", u->name);

    assert(u->run != NULL);

    ++suite->total;

    int result = setjmp(__unit_err);
    if (result == 0)
    {
        u->run();
        printf(" [OK]\n");
        ++suite->num_ok;
    }
    else
    {
        printf(" [FAIL]\n");
        ++suite->num_failed;
    }
    return 0;
}

inline static void run_unit_suite(struct unit_suite *suite)
{
    if (suite == NULL) return;

    printf("[SUITE] %s\n", suite->name);

    struct unit **u = suite->units;
    while (*u != NULL)
    {
        if (run_unit(suite, *u) != 0)
        {
            printf("[FRAMEWORK FAILURE]\n");
            abort();
        }
        ++u;
    }
}

#define __FUNCNAME(NAME) __unit_test_##NAME##_body
#define __UNITNAME(NAME) __unit_test_##NAME
#define UNIT(NAME) \
    static void __FUNCNAME(NAME)(); \
    static struct unit __UNITNAME(NAME) = { \
        .name = #NAME, \
        .run  = __FUNCNAME(NAME) \
    }; \
    static void __FUNCNAME(NAME)()

#define __SUITENAME(NAME) __unit_suite_##NAME
#define BEGIN_SUITE(NAME) \
    struct unit_suite __SUITENAME(NAME) = { \<commit_msg>Change empty argument lists to (void)<commit_after>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
#pragma once

#include <assert.h>
#include <float.h>
#include <inttypes.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

struct unit
{
    char const *name;
    void (*run)(void);
};

struct unit_suite
{
    char const *name;
    int total;
    int num_ok;
    int num_failed;
    struct unit *units[];
};

extern jmp_buf __unit_err;

inline static int run_unit(struct unit_suite *suite, struct unit *u)
{
    if (u == NULL) return 1;

    printf("  [TEST] %s ", u->name);

    assert(u->run != NULL);

    ++suite->total;

    int result = setjmp(__unit_err);
    if (result == 0)
    {
        u->run();
        printf(" [OK]\n");
        ++suite->num_ok;
    }
    else
    {
        printf(" [FAIL]\n");
        ++suite->num_failed;
    }
    return 0;
}

inline static void run_unit_suite(struct unit_suite *suite)
{
    if (suite == NULL) return;

    printf("[SUITE] %s\n", suite->name);

    struct unit **u = suite->units;
    while (*u != NULL)
    {
        if (run_unit(suite, *u) != 0)
        {
            printf("[FRAMEWORK FAILURE]\n");
            abort();
        }
        ++u;
    }
}

#define __FUNCNAME(NAME) __unit_test_##NAME##_body
#define __UNITNAME(NAME) __unit_test_##NAME
#define UNIT(NAME) \
    static void __FUNCNAME(NAME)(void); \
    static struct unit __UNITNAME(NAME) = { \
        .name = #NAME, \
        .run  = __FUNCNAME(NAME) \
    }; \
    static void __FUNCNAME(NAME)(void)

#define __SUITENAME(NAME) __unit_suite_##NAME
#define BEGIN_SUITE(NAME) \
    struct unit_suite __SUITENAME(NAME) = { \
{'fraction_non_alphanumeric': 0.15059897318881918, 'fraction_numerical': 0.004563605248146035, 'mean_word_length': 2.571283095723014, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 35, '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': '7510730', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1224, 'n_words': 327}