<commit_before>/**
 * FreeRDP: A Remote Desktop Protocol Client
 * List Unit Tests
 *
 * Copyright 2011 <NAME>
 *
 * 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.
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/list.h>

#include "test_list.h"

int init_list_suite(void)
{
	return 0;
}

int clean_list_suite(void)
{
	return 0;
}

int add_list_suite(void)
{
	add_test_suite(list);

	add_test_function(list);

	return 0;
}

struct my_list_item
{
	uint32 a;
	uint32 b;
};

DEFINE_LIST_TYPE(my_list, my_list_item);

void my_list_item_free(struct my_list_item* item)
{
	item->a = 0;
	item->b = 0;
}

void test_list(void)
{
	struct my_list* list;
	struct my_list_item* item;
	struct my_list_item* item1;
	struct my_list_item* item2;
	int i;

	list = my_list_new();

	for (i = 0; i < 10; i++)
	{
		item = my_list_item_new();
		item->a = i;
		item->b = i * i;
		my_list_enqueue(list, item);
	}

	for (i = 0, item = list->head; item; i++, item = my_list_item_next(item))
	{
		CU_ASSERT(item->a == i);
		CU_ASSERT(item->b == i * i);
		/*printf("%d %d\n", item->a, item->b);*/
	}

	item1 = my_list_item_new();
	my_list_add(list, item1);
	item2 = my_list_item_new();
	my_list_add(list, item2);

	CU_ASSERT(my_list_remove(list, item1) == item1);
	my_list_item_free(item1);
	CU_ASSERT(my_list_remove(list, item2) == item2);
	CU_ASSERT(my_list_remove(list, item2) == NULL);
	my_list_item_free(item2);

	my_list_free(list);
}
<commit_msg>Don't leak test items in list unit test<commit_after>/**
 * FreeRDP: A Remote Desktop Protocol Client
 * List Unit Tests
 *
 * Copyright 2011 <NAME>
 *
 * 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.
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/list.h>

#include "test_list.h"

int init_list_suite(void)
{
	return 0;
}

int clean_list_suite(void)
{
	return 0;
}

int add_list_suite(void)
{
	add_test_suite(list);

	add_test_function(list);

	return 0;
}

struct my_list_item
{
	uint32 a;
	uint32 b;
};

DEFINE_LIST_TYPE(my_list, my_list_item);

void my_list_item_free(struct my_list_item* item)
{
	item->a = 0;
	item->b = 0;
}

void test_list(void)
{
	struct my_list* list;
	struct my_list_item* item;
	struct my_list_item* item1;
	struct my_list_item* item2;
	int i;

	list = my_list_new();

	for (i = 0; i < 10; i++)
	{
		item = my_list_item_new();
		item->a = i;
		item->b = i * i;
		my_list_enqueue(list, item);
	}

	for (i = 0, item = list->head; item; i++, item = my_list_item_next(item))
	{
		CU_ASSERT(item->a == i);
		CU_ASSERT(item->b == i * i);
		/*printf("%d %d\n", item->a, item->b);*/
	}

	item1 = my_list_item_new();
	my_list_add(list, item1);
	item2 = my_list_item_new();
	my_list_add(list, item2);

	CU_ASSERT(my_list_remove(list, item1) == item1);
	my_list_item_free(item1);
	xfree(item1);
	CU_ASSERT(my_list_remove(list, item2) == item2);
	CU_ASSERT(my_list_remove(list, item2) == NULL);
	my_list_item_free(item2);
	xfree(item2);

	my_list_free(list);
}

{'fraction_non_alphanumeric': 0.13216403162055335, 'fraction_numerical': 0.017292490118577076, 'mean_word_length': 4.313648293963254, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, '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': '3990010', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1546, 'n_words': 417}