<commit_before>/*
	Copyright 2014 <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.
*/

/* Includes ------------------------------------------------------------------*/
#include "unity_fixture.h"
#include "tests/memmgr_unity.h"
#include "os/memmgr.h"
#include "os/mutex.h"

/*----------------------------------------------------------------------------*/
static mutex_t *gs_mtx = NULL;

/* Test group definitions ----------------------------------------------------*/
TEST_GROUP(mutex);

TEST_GROUP_RUNNER(mutex)
{
	RUN_TEST_CASE(mutex, to_string);
}

TEST_SETUP(mutex)
{
	unity_mock_setup();
	gs_mtx = mutex_new(false, "unit_tests");

}

TEST_TEAR_DOWN(mutex)
{
	object_delete(&gs_mtx->base);
	gs_mtx = NULL;
}

/* Tests ---------------------------------------------------------------------*/
TEST(mutex, to_string)
{
	char *string = object_to_string(&gs_mtx->base);
	TEST_ASSERT_EQUAL_STRING("unit_tests", string);
	mm_free(string);
}<commit_msg>check that locking/unlocking null mutex will die.<commit_after>/*
	Copyright 2014 <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.
*/

/* Includes ------------------------------------------------------------------*/
#include "unity_fixture.h"
#include "tests/memmgr_unity.h"
#include "os/memmgr.h"
#include "os/mutex.h"

/*----------------------------------------------------------------------------*/
static mutex_t *gs_mtx = NULL;

/* Test group definitions ----------------------------------------------------*/
TEST_GROUP(mutex);

TEST_GROUP_RUNNER(mutex)
{
	RUN_TEST_CASE(mutex, to_string);
	RUN_TEST_CASE(mutex, lock_null_should_die);
	RUN_TEST_CASE(mutex, unlock_null_should_die);
}

TEST_SETUP(mutex)
{
	unity_mock_setup();
	gs_mtx = mutex_new(false, "unit_tests");

}

TEST_TEAR_DOWN(mutex)
{
	object_delete(&gs_mtx->base);
	gs_mtx = NULL;
}

/* Tests ---------------------------------------------------------------------*/
TEST(mutex, to_string)
{
	char *string = object_to_string(&gs_mtx->base);
	TEST_ASSERT_EQUAL_STRING("unit_tests", string);
	mm_free(string);
}

TEST(mutex, lock_null_should_die)
{
	EXPECT_ABORT_BEGIN
	mutex_lock(NULL, -1);
	VERIFY_FAILS_END("null mutex");
}

TEST(mutex, unlock_null_should_die)
{
	EXPECT_ABORT_BEGIN
	mutex_unlock(NULL);
	VERIFY_FAILS_END("null mutex");
}
{'fraction_non_alphanumeric': 0.25495049504950495, 'fraction_numerical': 0.00525990099009901, 'mean_word_length': 2.3364293085655317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3669137', 'n_tokens_mistral': 975, 'n_tokens_neox': 948, 'n_words': 263}