<commit_before>#include "CppUTest/TestHarness.h"
#include "CppUTest/TestMemoryAllocator.h"
#include "CppUTest/MemoryLeakDetector.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/TestRegistry.h"
#include "CppUTest/TestTestingFixture.h"
#include "CppUTest/PlatformSpecificFunctions.h"
#include "AllocationInCppFile.h"
extern "C"
{
#include "AllocationInCFile.h"
}

TEST_GROUP(BasicBehavior)
{
};

TEST(BasicBehavior, CanDeleteNullPointers)
{
	delete (char*) NULL;
	delete [] (char*) NULL;
}

#ifndef CPPUTEST_MEM_LEAK_DETECTION_DISABLED

TEST(BasicBehavior, deleteArrayInvalidatesMemory)
{
	unsigned char* memory = new unsigned char[10];
	PlatformSpecificMemset(memory, 0xAB, 10);
	delete [] memory;
	CHECK(memory[5] != 0xCB);
}

TEST(BasicBehavior, deleteInvalidatesMemory)
{
	unsigned char* memory = new unsigned char;
	*memory = 0xAD;
	delete memory;
	CHECK(*memory != 0xAD);
}

TEST(BasicBehavior, bothMallocAndFreeAreOverloaded)
{
	void* memory = cpputest_malloc_location(sizeof(char), "file", 10);
	free(memory);

	memory = malloc(sizeof(unsigned char));
	cpputest_free_location(memory, "file", 10);
}

#endif

TEST(BasicBehavior, freeInvalidatesMemory)
{
	unsigned char* memory = (unsigned char*) cpputest_malloc(sizeof(unsigned char));
	*memory = 0xAD;
	cpputest_free(memory);<commit_msg>Check for proper memory overloads for malloc in C++<commit_after>#include "CppUTest/TestHarness.h"
#include "CppUTest/TestMemoryAllocator.h"
#include "CppUTest/MemoryLeakDetector.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/TestRegistry.h"
#include "CppUTest/TestTestingFixture.h"
#include "CppUTest/PlatformSpecificFunctions.h"
#include "AllocationInCppFile.h"
extern "C"
{
#include "AllocationInCFile.h"
}

TEST_GROUP(BasicBehavior)
{
};

TEST(BasicBehavior, CanDeleteNullPointers)
{
	delete (char*) NULL;
	delete [] (char*) NULL;
}

#ifndef CPPUTEST_MEM_LEAK_DETECTION_DISABLED

TEST(BasicBehavior, deleteArrayInvalidatesMemory)
{
	unsigned char* memory = new unsigned char[10];
	PlatformSpecificMemset(memory, 0xAB, 10);
	delete [] memory;
	CHECK(memory[5] != 0xCB);
}

TEST(BasicBehavior, deleteInvalidatesMemory)
{
	unsigned char* memory = new unsigned char;
	*memory = 0xAD;
	delete memory;
	CHECK(*memory != 0xAD);
}

#if CPPUTEST_USE_STD_CPP_LIB
#include <cstdlib>
#endif

TEST(BasicBehavior, bothMallocAndFreeAreOverloaded)
{
	void* memory = cpputest_malloc_location(sizeof(char), "file", 10);
	free(memory);

	memory = malloc(sizeof(unsigned char));
	cpputest_free_location(memory, "file", 10);
}

#endif

TEST(BasicBehavior, freeInvalidatesMemory)
{
	unsigned char* memory = (unsigned char*) cpputest_malloc(sizeof(unsigned char));
	*memory = 0xAD;
	cpputest_free(memory);
{'fraction_non_alphanumeric': 0.12657757980697848, 'fraction_numerical': 0.010393466963622866, 'mean_word_length': 7.448275862068965, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2754300', 'n_tokens_mistral': 996, 'n_tokens_neox': 974, 'n_words': 186}