Skip to content

Github Actions now working - my own tester

Compare
Choose a tag to compare
@biralavor biralavor released this 13 May 19:08
· 357 commits to main since this release

I had write a super simplified tester, just to understand how Github Action works.

While I was into this endeavor, I had several issues:

  • LIBFT not linking
  • two main() functions -> my tester and my program to test
  • CUnit not fully working
  • and more...

So..., I tried to reduce scope. That's why I built my own tester.

This is the main code, after spliting the functions and main at my program to test:

#include <stdio.h>
#include "push_swap.h"
#include "../../program_to_test/src/push_functions.c"

void	test_pushadd_5plus4()
{
	// ARRANGE
	int	actual_result;
	int	expected_result = 9;

	// ACT
	actual_result = push_add(5, 4);

	// ASSERT
	if (expected_result != actual_result)
	{
		ft_error_msg("Test failed: test_pushadd_5plus4\n");
	}
}

void	test_pushsubtract_5minus3()
{
	// ARRANGE
	int	actual_result;
	int	expected_result = 2;

	// ACT
	actual_result = push_subtract(5, 3);

	// ASSERT
	if (expected_result != actual_result)
	{
		ft_error_msg("Test failed: test_pushsubtract_5minus3\n");
	}
}

int main(void)
{
	int	index;

	index = 0;
	ft_printf("\033[0;36m");
	ft_printf("Runing test [%d] test_pushadd_5plus4\n", ++index);
	test_pushadd_5plus4();
	ft_printf("Runing test [%d] test_pushsubtract_5minus3\n", ++index);
	test_pushsubtract_5minus3();
	ft_printf("All tests passed\n");
	return (0);
}