diff --git a/Task 1/unittest_1.cpp b/Task 1/unittest_1.cpp index 26eb8986be03491fd5a9157af4fab1300b4d9cf0..6220680ce849a8e485b4b527ab4f7ae64cd15d2e 100644 --- a/Task 1/unittest_1.cpp +++ b/Task 1/unittest_1.cpp @@ -27,9 +27,12 @@ DEFINE_TEST(TestFiberStackAlignment) { TEST_EQ(stackPtr % 16, 0); // Stack should be 16-byte aligned } -// Test Fiber Stack Size +// Test Fiber Stack Alignment and Pointer Position DEFINE_TEST(TestFiberStackAlignmentAndPosition) { - Fiber testFiber([](Context*, Context*){}, nullptr); + Fiber testFiber([](Context* mainContext, Context* selfContext) { + // Dummy function for fiber + }); + uintptr_t stackPtr = reinterpret_cast<uintptr_t>(testFiber.context.rsp); // Check alignment @@ -37,10 +40,11 @@ DEFINE_TEST(TestFiberStackAlignmentAndPosition) { // Assuming the stack grows downwards, stackPtr should be less than the address of stack[] uintptr_t stackArrayPtr = reinterpret_cast<uintptr_t>(testFiber.stack); - TEST_TRUE(stackPtr < stackArrayPtr); - TEST_TRUE(stackPtr >= stackArrayPtr - StackSize); // Within the bounds of the stack + TEST(stackPtr < stackArrayPtr); + TEST(stackPtr >= stackArrayPtr - StackSize); // Within the bounds of the stack } + // Test Fiber Context Initialization DEFINE_TEST(TestFiberContextInitialization) { Fiber testFiber([](Context* mc, Context* sc){ swap_context(sc, mc); });