This commit is contained in:
seleznevae
2018-01-01 21:45:01 +03:00
parent cc06b4c22f
commit 31fa1a1d74
3 changed files with 238 additions and 35 deletions

View File

@@ -1,20 +1,31 @@
#include "tests.h"
#include "fort.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
void test_table_basic(void **state)
{
(void)state;
FTABLE *table = ft_create_table();
int n = ft_hdr_printf(table, "%d , %c|| %s|%f", 3, 'c', "234", 3.14);
assert_true( n == 4 );
// assert_true( n == 4 );
n = ft_row_printf(table, 0, "%d , %c|| %s|%f", 3, 'c', "234", 3.14);
assert_true( n == 4 );
n = ft_row_printf(table, 1, "%d , %c|| %s|%f", 3, 'c', "234", 3.14);
assert_true( n == 4 );
// const char *table_str = ft_to_string(table);
// const char *table_str_etalon = "| 3 , c| | 234| 3.140000";
// assert_true( strcmp(table_str, table_str_etalon) == 0);
char *table_str = ft_to_string(table);
const char *table_str_etalon =
"| 3 , c| | 234| 3.140000\n"
"| 3 , c| | 234| 3.140000\n"
"| 3 , c| | 234| 3.140000\n";
assert_true( strcmp(table_str, table_str_etalon) == 0);
free(table_str);
ft_destroy_table(table);
}