added more unit tests for test_stack.c

This commit is contained in:
= 2025-12-04 19:30:33 +01:00
parent 204f2a2526
commit 64a16f06d7
3 changed files with 14 additions and 1 deletions

Binary file not shown.

View File

@ -37,6 +37,18 @@ void test_topReturnsCorrectValue(void) {
clearStack(startNode);
}
void test_topReturnsNullOnNotExistingStack(void) {
// 1. Arrange
StackNode* startNode = NULL;
int* data;
// 2. Act
data = top(startNode);
//3. Assert
TEST_ASSERT_NULL(data);
}
void test_popRemovesElements(void) {
// 1. Arrange
StackNode* startNode = NULL;
@ -70,6 +82,7 @@ int main(void) {
printf("\n============================\nStack tests\n============================\n");
RUN_TEST(test_topReturnsNullOnNotExistingStack);
RUN_TEST(test_topReturnsCorrectValue);
RUN_TEST(test_popRemovesElements);