<commit_before>/* just some additional macros to help with unit testing*/
#ifndef RF_UNIT_TESTS_HELPERS
#define RF_UNIT_TESTS_HELPERS

#include <Utils/constcmp.h>
#include <String/rf_str_common.h>
#include <string.h>

/* non null terminated cstring related macros */
#define ck_assert_nnt_str_eq_cstr(nnt_, cstr_)                  \
    ck_assert_msg(0 == strncmp((nnt_), (cstr_), strlen(cstr_)))

/* RFstring/x related macros */
#define ck_assert_rf_str_eq_cstr(rfstr_, cstr_)                       \
    do {                                                              \
        ck_assert_msg(                                                \
            0 == memcmp(rf_string_data(rfstr_),                       \
                        cstr_, strlen(cstr_)),                        \
            "\""RF_STR_PF_FMT"\" != \"%s\"",                          \
            RF_STR_PF_ARG(rfstr_), (cstr_));                          \
        ck_assert_msg(                                                \
            rf_string_length_bytes(rfstr_) == strlen(cstr_),          \
            "len of RFstring \""RF_STR_PF_FMT"\"(%u) != "             \
            "len of cstr \"%s\"(%u)", RF_STR_PF_ARG(rfstr_),          \
            rf_string_length_bytes(rfstr_), (cstr_), strlen(cstr_));  \
    } while(0)


#define ck_assert_rf_strx_eq_cstr(str_, lit_)                           \
    do{                                                                 \
        ck_assert_uint_ge(((struct RFstringx*)str_)->bSize, strlen(lit_)); \
        ck_assert_msg(0 == memcmp(rf_string_data(str_), lit_, strlen(lit_)), \
                      "\""RF_STR_PF_FMT"\" != \"%s\"", RF_STR_PF_ARG((str_)), (lit_)); \
        ck_assert_int_eq(rf_string_data(str_)[((struct RFstringx*)str_)->bIndex], \
                         lit_[0]);                                      \
    }while(0)

#define ck_assert_rf_str_empty(str_) \<commit_msg>Test macro to compare rfstring to non null terminated string<commit_after>/* just some additional macros to help with unit testing*/
#ifndef RF_UNIT_TESTS_HELPERS
#define RF_UNIT_TESTS_HELPERS

#include <Utils/constcmp.h>
#include <String/rf_str_common.h>
#include <string.h>

/* non null terminated cstring related macros */
#define ck_assert_nnt_str_eq_cstr(nnt_, cstr_)                  \
    ck_assert_msg(0 == strncmp((nnt_), (cstr_), strlen(cstr_)))

/* RFstring/x related macros */
#define ck_assert_rf_str_eq_cstr(rfstr_, cstr_)                       \
    do {                                                              \
        ck_assert_msg(                                                \
            0 == memcmp(rf_string_data(rfstr_),                       \
                        cstr_, strlen(cstr_)),                        \
            "\""RF_STR_PF_FMT"\" != \"%s\"",                          \
            RF_STR_PF_ARG(rfstr_), (cstr_));                          \
        ck_assert_msg(                                                \
            rf_string_length_bytes(rfstr_) == strlen(cstr_),          \
            "len of RFstring \""RF_STR_PF_FMT"\"(%u) != "             \
            "len of cstr \"%s\"(%u)", RF_STR_PF_ARG(rfstr_),          \
            rf_string_length_bytes(rfstr_), (cstr_), strlen(cstr_));  \
    } while(0)

#define ck_assert_rf_str_eq_nntstr(rfstr_, nntstr_, length_)            \
    do {                                                                \
        ck_assert_msg(                                                  \
            0 == memcmp(rf_string_data(rfstr_),                         \
                        nntstr_, length_),                              \
            "\""RF_STR_PF_FMT"\" != \"%.*s\"",                          \
            RF_STR_PF_ARG(rfstr_), (length_), (nntstr_));               \
        ck_assert_msg(                                                  \
            rf_string_length_bytes(rfstr_) == (length_),                \
            "len of RFstring \""RF_STR_PF_FMT"\"(%u) != "               \
            "len of non null terminated string \"%.*s\"(%u)", RF_STR_PF_ARG(rfstr_), \
            rf_string_length_bytes(rfstr_), (length_), (nntstr_), (length_)); \
    } while(0)


#define ck_assert_rf_strx_eq_cstr(str_, lit_)                           \
    do{                                                                 \
        ck_assert_uint_ge(((struct RFstringx*)str_)->bSize, strlen(lit_)); \
        ck_assert_msg(0 == memcmp(rf_string_data(str_), lit_, strlen(lit_)), \
                      "\""RF_STR_PF_FMT"\" != \"%s\"", RF_STR_PF_ARG((str_)), (lit_)); \
        ck_assert_int_eq(rf_string_data(str_)[((struct RFstringx*)str_)->bIndex], \
                         lit_[0]);                                      \
    }while(0)

#define ck_assert_rf_str_empty(str_) \
{'fraction_non_alphanumeric': 0.12085406301824213, 'fraction_numerical': 0.002902155887230514, 'mean_word_length': 1.2112740604949588, 'pattern_counts': {'":': 0, '<': 9, '<?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': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876730', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1416, 'n_words': 216}