64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
#include <criterion/criterion.h>
|
|
#include <stdio.h>
|
|
|
|
#include "internal/transpile_internal.h"
|
|
|
|
/*
|
|
** TESTS: transpile/state.c - State initialization
|
|
*/
|
|
|
|
Test(transpile_state, init_sets_all_fields)
|
|
{
|
|
t_state s;
|
|
FILE *in;
|
|
FILE *out;
|
|
t_map map;
|
|
const char *ext = "c";
|
|
|
|
in = fopen("/tmp/test_state_in.md", "w");
|
|
out = fopen("/tmp/test_state_out.c", "w");
|
|
map_init(&map);
|
|
|
|
state_init(&s, in, out, ext, &map);
|
|
|
|
cr_assert_eq(s.in, in);
|
|
cr_assert_eq(s.out, out);
|
|
cr_assert_str_eq(s.ext, "c");
|
|
cr_assert_eq(s.map, &map);
|
|
cr_assert_eq(s.src_line, 0);
|
|
cr_assert_eq(s.dst_line, 0);
|
|
cr_assert_eq(s.block_src_start, 0);
|
|
cr_assert_eq(s.block_dst_start, 0);
|
|
cr_assert_eq(s.in_block, 0);
|
|
cr_assert_eq(s.first_block, 1);
|
|
|
|
fclose(in);
|
|
fclose(out);
|
|
map_free(&map);
|
|
remove("/tmp/test_state_in.md");
|
|
remove("/tmp/test_state_out.c");
|
|
}
|
|
|
|
Test(transpile_state, init_with_different_extension)
|
|
{
|
|
t_state s;
|
|
FILE *in;
|
|
FILE *out;
|
|
t_map map;
|
|
const char *ext = "py";
|
|
|
|
in = fopen("/tmp/test_state_in.md", "w");
|
|
out = fopen("/tmp/test_state_out.py", "w");
|
|
map_init(&map);
|
|
|
|
state_init(&s, in, out, ext, &map);
|
|
|
|
cr_assert_str_eq(s.ext, "py");
|
|
cr_assert_eq(s.first_block, 1);
|
|
|
|
fclose(in);
|
|
fclose(out);
|
|
map_free(&map);
|
|
remove("/tmp/test_state_in.md");
|
|
remove("/tmp/test_state_out.py");
|
|
}
|