<commit_before>/*
* Copyright (c) 2010 MLBA. All rights reserved.
*
* @MLBA_OPEN_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*     http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @MLBA_OPEN_LICENSE_HEADER_END@
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// memory leak detection on windows
#if defined(_WIN32) && defined(DEBUG) && !defined(__GNUC__)
#	define _CRTDBG_MAP_ALLOC
#	include <stdlib.h>
#	include <crtdbg.h>
#	include <Windows.h>
#endif

#include "MUnit_assert.h"
#include "MUnit_tools.h"
#include "typedefs.h"
#include "private.h"

void _pass(const char *msg, const char *file, int line){
    printf("    PASS\n");
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_SUCCESS);
}

void _pass_after_delay(void* d){
    printf("    PASS\n");
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_SUCCESS);
}

void _fail(const char *msg, const char *file, int line){
    printf(" FAIL:\n\t%s\n\t- at %s:%u\n",msg,file,line);
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_FAILURE);
}

#ifdef _WIN32
# define inline _inline
#endif

static inline void _assert_eval(const char* msg, bool cond, const char* file, int line){
    if(!cond) {
        _fail(msg,file,line);
    } else if(verbose) {
        printf("\t%s\n\tOK\n", msg);
        fflush(stdout);
    }
}

void _assert_true_long(long a, long b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is %li, %li",cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert %s \n\t- is %li, %li",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_true_hex(long a, long b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_true_double(double a, double b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is %f, %f", cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert %s \n\t- is %f, %f", cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_long(long a, long b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is %li, %li",cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert not %s \n\t- is %li, %li",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_hex(long a, long b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert not %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_double(double a, double b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is %f, %f",cond_desc, a, b);
#else
    sprintf_s(msg, 100,"Assert not %s \n\t- is %f, %f",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}<commit_msg>Share changes from stable into trunk<commit_after>/*
* Copyright (c) 2010 MLBA. All rights reserved.
*
* @MLBA_OPEN_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*     http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @MLBA_OPEN_LICENSE_HEADER_END@
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// memory leak detection on windows
#if defined(_WIN32) && defined(DEBUG) && !defined(__GNUC__)
#	define _CRTDBG_MAP_ALLOC
#	include <stdlib.h>
#	include <crtdbg.h>
#	include <Windows.h>
#endif

#include "MUnit_assert.h"
#include "MUnit_tools.h"
#include "typedefs.h"
#include "private.h"

void _pass(const char *msg, const char *file, int line){
    printf("    PASS\n");
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_SUCCESS);
}

void _pass_after_delay(void* d){
    printf("    PASS\n");
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_SUCCESS);
}

void _fail(const char *msg, const char *file, int line){
    printf(" FAIL:\n\t%s\n\t- at %s:%u\n",msg,file,line);
    //#if defined(WIN32) && defined(DEBUG)
    //	Sleep(2000);
    //	_CrtDumpMemoryLeaks();
    //#endif
	exit(EXIT_FAILURE);
}

#ifdef _WIN32
# define inline _inline
#endif

static inline void _assert_eval(const char* msg, bool cond, const char* file, int line){
    if(!cond) {
        _fail(msg,file,line);
    } else if(verbose) {
        printf("\t%s\n\tOK\n", msg);
        fflush(stdout);
    }
}

void _assert_true_long(long a, long b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is %li, %li",cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert %s \n\t- is %li, %li",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_true_hex(long a, long b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_true_double(double a, double b, bool cond, const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert %s \n\t- is %f, %f", cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert %s \n\t- is %f, %f", cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_long(long a, long b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is %li, %li",cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert not %s \n\t- is %li, %li",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_hex(long a, long b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert not %s \n\t- is 0x%lo, 0x%lo",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}

void _assert_not_true_double(double a, double b, bool cond,  const char* cond_desc, const char* file, int line){
    char msg[512];
#ifndef _WIN32
    sprintf(msg,"Assert not %s \n\t- is %f, %f",cond_desc, a, b);
#else
    sprintf_s(msg, 500,"Assert not %s \n\t- is %f, %f",cond_desc, a, b);
#endif
    _assert_eval(msg, cond, file, line);
}
{'fraction_non_alphanumeric': 0.15330923594665338, 'fraction_numerical': 0.021438364701483234, 'mean_word_length': 3.8279181708784598, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6678431', 'n_tokens_mistral': 3158, 'n_tokens_neox': 3038, 'n_words': 917}