Compare commits
No commits in common. "25a3cc313ef4af88990b999bcd229fba32c77464" and "3af4676c8342ab3722bc58d8f8b5414ba016aa1d" have entirely different histories.
25a3cc313e
...
3af4676c83
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(blt-gp VERSION 0.0.106)
|
project(blt-gp VERSION 0.0.104)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,9 @@ struct large_2048
|
||||||
blt::u8 data[2048];
|
blt::u8 data[2048];
|
||||||
};
|
};
|
||||||
|
|
||||||
// not actually 4096 but will fill the whole page (4096)
|
|
||||||
struct large_4096
|
struct large_4096
|
||||||
{
|
{
|
||||||
blt::u8 data[4096 - blt::gp::stack_allocator::page_size_no_block()];
|
blt::u8 data[4096];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct large_6123
|
struct large_6123
|
||||||
|
@ -250,37 +249,22 @@ void test_basic_types()
|
||||||
}
|
}
|
||||||
|
|
||||||
blt::gp::operation_t basic_2([](float a, float b) {
|
blt::gp::operation_t basic_2([](float a, float b) {
|
||||||
BLT_ASSERT(a == 50.0f);
|
|
||||||
BLT_ASSERT(b == 10.0f);
|
|
||||||
return a + b;
|
return a + b;
|
||||||
});
|
});
|
||||||
|
|
||||||
blt::gp::operation_t basic_mixed_4([](float a, float b, bool i, bool p) {
|
blt::gp::operation_t basic_mixed_4([](float a, float b, bool i, bool p) {
|
||||||
BLT_ASSERT(a == 50.0f);
|
|
||||||
BLT_ASSERT(b == 10.0f);
|
|
||||||
BLT_ASSERT(i);
|
|
||||||
BLT_ASSERT(!p);
|
|
||||||
return (a * (i ? 1.0f : 0.0f)) + (b * (p ? 1.0f : 0.0f));
|
return (a * (i ? 1.0f : 0.0f)) + (b * (p ? 1.0f : 0.0f));
|
||||||
});
|
});
|
||||||
|
|
||||||
blt::gp::operation_t large_256_basic_3([](const large_256& l, float a, float b) {
|
blt::gp::operation_t large_256_basic_3([](const large_256& l, float a, float b) {
|
||||||
BLT_ASSERT(compare(l, base_256) == -1);
|
blt::black_box(a);
|
||||||
BLT_ASSERT_MSG(a == 691, std::to_string(a).c_str());
|
blt::black_box(b);
|
||||||
BLT_ASSERT_MSG(b == 69.420f, std::to_string(b).c_str());
|
|
||||||
return blt::black_box_ret(l);
|
return blt::black_box_ret(l);
|
||||||
});
|
});
|
||||||
|
|
||||||
blt::gp::operation_t large_4096_basic_3b([](const large_4096& l, float a, bool b) {
|
blt::gp::operation_t large_2048_basic_3b([](const large_2048& l, float a, bool b) {
|
||||||
BLT_ASSERT(compare(l, base_4096) == -1);
|
blt::black_box(a);
|
||||||
BLT_ASSERT(a == 33);
|
blt::black_box(b);
|
||||||
BLT_ASSERT(b);
|
|
||||||
return blt::black_box_ret(l);
|
|
||||||
});
|
|
||||||
|
|
||||||
blt::gp::operation_t large_18290_basic_3b([](const large_18290& l, float a, bool b) {
|
|
||||||
BLT_ASSERT(compare(l, base_18290) == -1);
|
|
||||||
BLT_ASSERT(a == -2543);
|
|
||||||
BLT_ASSERT(b);
|
|
||||||
return blt::black_box_ret(l);
|
return blt::black_box_ret(l);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -291,7 +275,6 @@ void test_basic()
|
||||||
blt::gp::stack_allocator stack;
|
blt::gp::stack_allocator stack;
|
||||||
stack.push(50.0f);
|
stack.push(50.0f);
|
||||||
stack.push(10.0f);
|
stack.push(10.0f);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
auto val = stack.pop<float>();
|
auto val = stack.pop<float>();
|
||||||
|
@ -309,7 +292,6 @@ void test_basic()
|
||||||
BLT_TRACE_STREAM << size << "\n";
|
BLT_TRACE_STREAM << size << "\n";
|
||||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||||
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<float>();
|
auto val = stack.pop<float>();
|
||||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||||
RUN_TEST(val != 60.000000f, stack, "Basic 2 Boundary Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
|
RUN_TEST(val != 60.000000f, stack, "Basic 2 Boundary Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
|
||||||
|
@ -327,13 +309,12 @@ void test_mixed()
|
||||||
stack.push(10.0f);
|
stack.push(10.0f);
|
||||||
stack.push(true);
|
stack.push(true);
|
||||||
stack.push(false);
|
stack.push(false);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
auto val = stack.pop<float>();
|
auto val = stack.pop<float>();
|
||||||
RUN_TEST(val != 50.000000f, stack, "Mixed 4 Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
RUN_TEST(val != 50.000000f, stack, "Mixed 4 Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation.");
|
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation.");
|
||||||
}
|
}
|
||||||
BLT_INFO("Testing mixed with stack over boundary");
|
BLT_INFO("Testing mixed with stack over boundary");
|
||||||
{
|
{
|
||||||
|
@ -341,88 +322,17 @@ void test_mixed()
|
||||||
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
|
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
|
||||||
stack.push(50.0f);
|
stack.push(50.0f);
|
||||||
stack.push(10.0f);
|
stack.push(10.0f);
|
||||||
stack.push(true);
|
|
||||||
stack.push(false);
|
stack.push(false);
|
||||||
|
stack.push(true);
|
||||||
auto size = stack.size();
|
auto size = stack.size();
|
||||||
BLT_TRACE_STREAM << size << "\n";
|
BLT_TRACE_STREAM << size << "\n";
|
||||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||||
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<float>();
|
auto val = stack.pop<float>();
|
||||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||||
RUN_TEST(val != 50.000000f, stack, "Mixed 4 Boundary Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
RUN_TEST(val != 10.000000f, stack, "Mixed 4 Boundary Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation over stack boundary");
|
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation over stack boundary");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_large_256()
|
|
||||||
{
|
|
||||||
BLT_INFO("Testing large 256 with stack");
|
|
||||||
{
|
|
||||||
blt::gp::stack_allocator stack;
|
|
||||||
stack.push(base_256);
|
|
||||||
stack.push(691.0f);
|
|
||||||
stack.push(69.420f);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
large_256_basic_3.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<large_256>();
|
|
||||||
RUN_TEST(!compare(val, base_256), stack, "Large 256 3 Test Passed", "Large 256 3 Test Failed. Unexpected value produced '%lf'", val);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation.");
|
|
||||||
}
|
|
||||||
BLT_INFO("Testing large 256 with stack over boundary");
|
|
||||||
{
|
|
||||||
blt::gp::stack_allocator stack;
|
|
||||||
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(large_256)>{});
|
|
||||||
stack.push(base_256);
|
|
||||||
stack.push(691.0f);
|
|
||||||
stack.push(69.420f);
|
|
||||||
auto size = stack.size();
|
|
||||||
BLT_TRACE_STREAM << size << "\n";
|
|
||||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
|
||||||
large_256_basic_3.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<large_256>();
|
|
||||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(large_256)>>();
|
|
||||||
RUN_TEST(!compare(val, base_256), stack, "Large 256 3 Boundary Test Passed", "Large 256 3 Test Failed. Unexpected value produced '%lf'", val);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation over stack boundary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_large_4096()
|
|
||||||
{
|
|
||||||
BLT_INFO("Testing large 4096 with stack");
|
|
||||||
{
|
|
||||||
blt::gp::stack_allocator stack;
|
|
||||||
stack.push(base_4096);
|
|
||||||
stack.push(33.0f);
|
|
||||||
stack.push(true);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
large_4096_basic_3b.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<large_4096>();
|
|
||||||
RUN_TEST(!compare(val, base_4096), stack, "Large 4096 3 Test Passed", "Large 4096 3 Test Failed. Unexpected value produced '%lf'", val);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation.");
|
|
||||||
}
|
|
||||||
BLT_INFO("Testing large 4096 with stack over boundary");
|
|
||||||
{
|
|
||||||
blt::gp::stack_allocator stack;
|
|
||||||
stack.push(base_4096);
|
|
||||||
stack.push(33.0f);
|
|
||||||
stack.push(true);
|
|
||||||
auto size = stack.size();
|
|
||||||
BLT_TRACE_STREAM << size << "\n";
|
|
||||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
|
||||||
large_4096_basic_3b.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
auto val = stack.pop<large_4096>();
|
|
||||||
RUN_TEST(!compare(val, base_256), stack, "Large 4096 3 Boundary Test Passed", "Large 4096 3 Test Failed. Unexpected value produced '%lf'", val);
|
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
|
||||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation over stack boundary");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,10 +342,6 @@ void test_operators()
|
||||||
test_basic();
|
test_basic();
|
||||||
BLT_NEWLINE();
|
BLT_NEWLINE();
|
||||||
test_mixed();
|
test_mixed();
|
||||||
BLT_NEWLINE();
|
|
||||||
test_large_256();
|
|
||||||
BLT_NEWLINE();
|
|
||||||
test_large_4096();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
Loading…
Reference in New Issue