Ejemplo n.º 1
0
int	main(int argc, char const** argv)
{
	t_htable	htable;

	/*
	 * 127 is prime number OK !!
	 */
	D_HTABLE(init)(&htable, 127, NULL);
	/*
	 * Here I add "42" in htable
	 * With data (void*)1;
	 * Because it's demonstration not the truth !
	 */
	D_HTABLE(add)(&htable, "42", (void*)7);
	D_HTABLE(add)(&htable, "paris", (void*)8);
	D_HTABLE(add)(&htable, "school", (void*)9);
	/*
	 * Print all table
	 */
	D_HTABLE(print)(&htable, uf_print_value);
	uf_print_variadic("The data assigned at 42 is %d\n", D_HTABLE(get)(&htable, "42"));
	/*
	 * Free memory again yes yes (wo)man !
	 */
	D_HTABLE(destroy)(&htable);
	(void)argc;
	(void)argv;
	return (0);
}
Ejemplo n.º 2
0
void		uf_unit_console_run(t_list *list)
{
	t_list_cell	*cell;
	t_unit_test	*test;

	cell = D_LIST(begin)(list);
	while (cell != NULL)
	{
		test = (t_unit_test*)cell->v_data;
		uf_print_variadic("\trunning test: %e%s%e\t...\t", 37, test->v_name, 0);
		test->f_func(test);
		if (test->v_failed == true)
			uf_print_variadic("%efailed%e\n", 31, 0);
		else
			uf_print_variadic("%epassed%e\n", 32, 0);
		cell = cell->v_next;
	}
}
Ejemplo n.º 3
0
int	main(int argc, char const** argv)
{
    /*
     * Convert 240 deg to rad
     */
    uf_print_variadic("Convert 240 deg to rad %d\n", (int)uf_deg_to_rad(240));
    /*
     * Convert 240 deg to rad
     */
    uf_print_variadic("Convert 4 rad to deg %d\n", (int)uf_rad_to_deg(4));
    /*
     * And absolue value
     */
    uf_print_variadic("Absolue value -42 = %d\n", (int)uf_abs(-42));
    (void)argc;
    (void)argv;
    return (0);
}
Ejemplo n.º 4
0
void	uf_unit_console_treat_help(t_unit *v_this)
{
	uf_unit_print_console(v_this, "Help", false, '-');
	uf_print_variadic("\n\t%eR%e - Run all tests in all contexts"
					"\n\t%eS%e - Select context to run"
					"\n\t%eL%e - Show all context"
					"\n\t%eF%e - Show failure from last test"
					"\n\t%eH%e - Show command"
					"\n\t%eQ%e - Quit the program\n",
					34, 0, 34, 0, 34, 0, 34, 0, 34, 0, 34, 0);
	uf_unit_print_console(v_this, "-", false, '-');
}
Ejemplo n.º 5
0
static void	uf_unit_console_failure_print_info(t_unit_test *t)
{
	t_list_cell		*cell;
	t_unit_assert	*ass;

	if (t->v_tested == true)
	{
		cell = D_LIST(begin)(&t->v_assert);
		if (cell == NULL)
			uf_print_variadic("\ttest: %e%s%e\t\t   V%e\n",
							  37, t->v_name, 32, 0);
		while (cell != NULL)
		{
			ass = (t_unit_assert *)cell->v_data;
			uf_print_variadic("\ttest: %e%s\t\t   %eX\033[0m\t   %s\t\t %d\n",
							  37, t->v_name, 31, ass->v_file, ass->v_line);
			cell = cell->v_next;
		}
	}
	else
		uf_print_variadic("\ttest: %e%s%e\t\tUntested%e\n",
						  37, t->v_name, 31, 0);
}
Ejemplo n.º 6
0
void	uf_unit_console_treat_run(t_unit *v_this)
{
	t_list_cell		*cell;
	t_unit_context	*ctxt;

	cell = D_LIST(begin)(&v_this->v_context);
	uf_unit_print_console(v_this, "Running", false, '-');
	while (cell != NULL)
	{
		ctxt = (t_unit_context*)cell->v_data;
		if (D_LIST(empty)(&ctxt->v_test) == false)
		{
			uf_print_variadic("\nrunning context: %e%s%e\n",
							35, ctxt->v_name, 0);
			uf_unit_console_run(&ctxt->v_test);
		}
		cell = cell->v_next;
	}
	uf_unit_print_console(v_this, "-", false, '-');
}
Ejemplo n.º 7
0
void	uf_unit_console_treat_failure(t_unit *v_this)
{
	t_list_cell		*cell;
	t_unit_context	*ctxt;

	cell = D_LIST(begin)(&v_this->v_context);
	uf_unit_print_console(v_this, "Failures", false, '-');
	uf_print_str("\t\tName\t\t Statut\t\tFile\t\tLine\n\n");
	while (cell != NULL)
	{
		ctxt = (t_unit_context*)cell->v_data;
		if (D_LIST(empty)(&ctxt->v_test) == false)
		{
			uf_print_variadic("\ncontext: %e%s%e\n",
							35, ctxt->v_name, 0);
			uf_unit_console_failure(&ctxt->v_test);
		}
		cell = cell->v_next;
	}
	uf_unit_print_console(v_this, "-", false, '-');
}
Ejemplo n.º 8
0
bool	uf_print_data(void *data)
{
	uf_print_variadic("Data = %d\n", (int)data);
	return (true);
}