<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <assert.h>
#include <sys/time.h>
#include "rbtree.h"

/* #define INIFNITE_TEST */
#define UNIQUE_NUMBERS_ARRAY_SIZE 7777

typedef struct
{
	RBNode node;
	char data[128];
} TreeItemData;

typedef TreeItemData *TreeItem;

static int
tree_comparator(const RBNode* a, const RBNode* b, void* arg)
{
	return strcmp(((const TreeItem)a)->data, ((const TreeItem)b)->data);
}

static void
tree_combiner(RBNode* existing, const RBNode* newdata, void* arg)
{
	/* do nothing */
}

static RBNode*
tree_allocfunc(void* arg)
{
	return malloc(sizeof(TreeItemData));
}

static void
tree_freefunc(RBNode* node, void* arg)
{
	free(node);
}

static void
tree_sprintfunc(RBNode* node, char* buff)
{
	strcpy(buff, ((TreeItemData*)node)->data);
}

static void
general_test()
{
	RBTree tree;
	bool isNew;
	TreeItemData item;
	TreeItem tmp;
	RBTreeLeftRightWalk lrw;
	char temp_buff[512];

	rb_create(&tree, sizeof(TreeItemData), tree_comparator, tree_combiner, tree_allocfunc, tree_freefunc, NULL);

	assert(rb_leftmost(&tree) == NULL);

	strcpy(item.data, "Item A");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);
	assert(rb_leftmost(&tree) != NULL);

	strcpy(item.data, "Item B");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);

	strcpy(item.data, "Item C");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);

	temp_buff[0] = 0;
	rb_begin_left_right_walk(&tree, &lrw);
	while( (tmp = (TreeItem)rb_left_right_walk(&lrw)) )
	{
		strcat(temp_buff, tmp->data);
		strcat(temp_buff, ",");
	}
	assert(strcmp(temp_buff, "Item A,Item B,Item C,") == 0);

	strcpy(item.data, "Item A");
	tmp = (TreeItem)rb_find(&tree, (RBNode*)&item);
	assert(tmp != NULL);

	strcpy(item.data, "Item C");
	tmp = (TreeItem)rb_find(&tree, (RBNode*)&item);<commit_msg>Increase code coverage<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <assert.h>
#include <sys/time.h>
#include "rbtree.h"

/* #define INIFNITE_TEST */
#define UNIQUE_NUMBERS_ARRAY_SIZE 7777

typedef struct
{
	RBNode node;
	char data[128];
} TreeItemData;

typedef TreeItemData *TreeItem;

static int
tree_comparator(const RBNode* a, const RBNode* b, void* arg)
{
	return strcmp(((const TreeItem)a)->data, ((const TreeItem)b)->data);
}

static void
tree_combiner(RBNode* existing, const RBNode* newdata, void* arg)
{
	/* do nothing */
}

static RBNode*
tree_allocfunc(void* arg)
{
	return malloc(sizeof(TreeItemData));
}

static void
tree_freefunc(RBNode* node, void* arg)
{
	free(node);
}

static void
tree_sprintfunc(RBNode* node, char* buff)
{
	strcpy(buff, ((TreeItemData*)node)->data);
}

static void
general_test()
{
	RBTree tree;
	bool isNew;
	TreeItemData item;
	TreeItem tmp;
	RBTreeLeftRightWalk lrw;
	char temp_buff[512];

	rb_create(&tree, sizeof(TreeItemData), tree_comparator, tree_combiner, tree_allocfunc, tree_freefunc, NULL);

	assert(rb_leftmost(&tree) == NULL);

	strcpy(item.data, "Item A");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);
	assert(rb_leftmost(&tree) != NULL);

	strcpy(item.data, "Item B");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);

	strcpy(item.data, "Item C");
	rb_insert(&tree, (RBNode*)&item, &isNew);
	assert(isNew);

	temp_buff[0] = 0;
	rb_begin_left_right_walk(&tree, &lrw);
	while( (tmp = (TreeItem)rb_left_right_walk(&lrw)) )
	{
		strcat(temp_buff, tmp->data);
		strcat(temp_buff, ",");
	}
	assert(strcmp(temp_buff, "Item A,Item B,Item C,") == 0);

	strcpy(item.data, "No Such Item");
	tmp = (TreeItem)rb_find(&tree, (RBNode*)&item);
	assert(tmp == NULL);

	strcpy(item.data, "Item A");
	tmp = (TreeItem)rb_find(&tree, (RBNode*)&item);
	assert(tmp != NULL);

	strcpy(item.data, "Item C");
	tmp = (TreeItem)rb_find(&tree, (RBNode*)&item);
{'fraction_non_alphanumeric': 0.17267306196525797, 'fraction_numerical': 0.006740990407052113, 'mean_word_length': 6.104972375690608, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '68196', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1548, 'n_words': 320}