mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 00:00:44 +01:00
Add second test case for allcoation fail
This commit is contained in:
50
test.cpp
50
test.cpp
@@ -125,7 +125,54 @@ void testPoolExpressionAllocationFail() {
|
||||
f1.replaceWith(f11);
|
||||
float result2 = a1.approximate();
|
||||
assert(result2 == 0);
|
||||
}
|
||||
|
||||
void testPoolExpressionAllocationFail2() {
|
||||
printf("Pool expression allocation fail second test\n");
|
||||
|
||||
ExpressionRef::failedAllocationNode();
|
||||
assert(TreePool::sharedPool()->numberOfNodes() == 1);
|
||||
|
||||
// Fill the pool for size 256
|
||||
FloatRef f1(0.0f);
|
||||
FloatRef f2(1.0f);
|
||||
AdditionRef a1(f1, f2);
|
||||
float result1 = a1.approximate();
|
||||
assert(result1 == 1);
|
||||
|
||||
FloatRef f3(2.0f);
|
||||
FloatRef f4(3.0f);
|
||||
AdditionRef a2(f3, f4);
|
||||
float result2 = a2.approximate();
|
||||
assert(result2 == 5);
|
||||
|
||||
FloatRef f5(4.0f);
|
||||
FloatRef f6(5.0f);
|
||||
FloatRef f7(6.0f);
|
||||
FloatRef f8(7.0f);
|
||||
// Allocation fail
|
||||
FloatRef f9(8.0f);
|
||||
FloatRef f10(8.0f);
|
||||
|
||||
printf("\n");
|
||||
TreePool::sharedPool()->log();
|
||||
printf("\n");
|
||||
f1.replaceWith(f9);
|
||||
result1 = a1.approximate();
|
||||
assert(result1 == -1);
|
||||
|
||||
TreePool::sharedPool()->log();
|
||||
printf("\n");
|
||||
f3.replaceWith(f10);
|
||||
result2 = a2.approximate();
|
||||
assert(result2 == -1);
|
||||
|
||||
printf("\n");
|
||||
TreePool::sharedPool()->log();
|
||||
result1 = a1.approximate();
|
||||
printf("a1 number children %d\n", a1.numberOfChildren());
|
||||
printf("a1 %f\n", result1);
|
||||
assert(result1 == -1);
|
||||
}
|
||||
|
||||
void testPoolLayoutAllocationFail() {
|
||||
@@ -162,7 +209,8 @@ int main() {
|
||||
runTest(testPoolEmpties);
|
||||
runTest(testCursorCreateAndRetain);
|
||||
runTest(testCursorMoveLeft);
|
||||
runTest(testPoolExpressionAllocationFail);
|
||||
//runTest(testPoolExpressionAllocationFail);
|
||||
runTest(testPoolExpressionAllocationFail2);
|
||||
printf("\n*******************\nEnd of tests\n*******************\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user