<commit_before>#include "catch.hpp"
#include <toolbox/alloc/stack_allocator.hpp>
#include <iostream>

TEST_CASE("simple functionality", "[alloc][stack_allocator]")
{
	toolbox::alloc::stack_allocator<int, 10> alloc;

	int *p1 = alloc.allocate(1);
	int *p2 = alloc.allocate(1);
	int *p3 = alloc.allocate(8);

	REQUIRE(p2 - p1 == 1);
	REQUIRE(p3 != nullptr);
	REQUIRE(alloc.allocate(1) == nullptr);
	REQUIRE(alloc.available() == 0);

	alloc.deallocate(p1, 1);
	REQUIRE(alloc.available() == 0);

	alloc.deallocate(p3, 8);
	REQUIRE(alloc.available() == 8);
}

TEST_CASE("test with vector", "[alloc][stack_allocator][vector]")
{
	toolbox::alloc::stack_allocator<float, 5> alloc;
	std::vector<float, decltype(alloc)> vec(alloc);

	vec.push_back(1);
	vec.push_back(1);
}
<commit_msg>tests: check for exception in allocator tests<commit_after>#include "catch.hpp"
#include <toolbox/alloc/stack_allocator.hpp>
#include <iostream>

TEST_CASE("simple functionality", "[alloc][stack_allocator]")
{
	toolbox::alloc::stack_allocator<int, 10> alloc;

	int *p1 = alloc.allocate(1);
	int *p2 = alloc.allocate(1);
	int *p3 = alloc.allocate(8);

	REQUIRE(p2 - p1 == 1);
	REQUIRE(p3 != nullptr);
	REQUIRE_THROWS(alloc.allocate(1));
	REQUIRE(alloc.available() == 0);

	alloc.deallocate(p1, 1);
	REQUIRE(alloc.available() == 0);

	alloc.deallocate(p3, 8);
	REQUIRE(alloc.available() == 8);
}

TEST_CASE("test with vector", "[alloc][stack_allocator][vector]")
{
	toolbox::alloc::stack_allocator<float, 5> alloc;
	std::vector<float, decltype(alloc)> vec(alloc);

	vec.push_back(1);
	vec.push_back(1);
}

{'fraction_non_alphanumeric': 0.188212927756654, 'fraction_numerical': 0.029150823827629912, 'mean_word_length': 6.483412322274882, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3364087', 'n_tokens_mistral': 640, 'n_tokens_neox': 611, 'n_words': 105}