oh, there's t_regression.c now, neat.

This commit is contained in:
Sven M. Hallberg 2015-01-30 20:42:11 +01:00
parent 3f197ea1b0
commit 12771a5655
2 changed files with 22 additions and 23 deletions

View file

@ -2,8 +2,6 @@
#include <string.h>
#include "test_suite.h"
#include "hammer.h"
#include "internal.h"
#include "glue.h"
static void test_tt_user(void) {
g_check_cmp_int32(TT_USER, >, TT_NONE);
@ -31,28 +29,7 @@ static void test_tt_registry(void) {
g_check_cmp_int32(h_get_token_type_number("com.upstandinghackers.test.unkown_token_type"), ==, 0);
}
static void test_seq_index_path(void) {
HArena *arena = h_new_arena(&system_allocator, 0);
HParsedToken *seq = h_make_seqn(arena, 1);
HParsedToken *seq2 = h_make_seqn(arena, 2);
HParsedToken *tok1 = h_make_uint(arena, 41);
HParsedToken *tok2 = h_make_uint(arena, 42);
seq->seq->elements[0] = seq2;
seq->seq->used = 1;
seq2->seq->elements[0] = tok1;
seq2->seq->elements[1] = tok2;
seq2->seq->used = 2;
g_check_cmp_int(h_seq_index_path(seq, 0, -1)->token_type, ==, TT_SEQUENCE);
g_check_cmp_int(h_seq_index_path(seq, 0, 0, -1)->token_type, ==, TT_UINT);
g_check_cmp_int64(h_seq_index_path(seq, 0, 0, -1)->uint, ==, 41);
g_check_cmp_int64(h_seq_index_path(seq, 0, 1, -1)->uint, ==, 42);
}
void register_misc_tests(void) {
g_test_add_func("/core/misc/tt_user", test_tt_user);
g_test_add_func("/core/misc/tt_registry", test_tt_registry);
g_test_add_func("/core/misc/seq_index_path", test_seq_index_path);
}

View file

@ -3,6 +3,7 @@
#include "glue.h"
#include "hammer.h"
#include "test_suite.h"
#include "internal.h"
static void test_bug118(void) {
// https://github.com/UpstandingHackers/hammer/issues/118
@ -33,6 +34,27 @@ static void test_bug118(void) {
h_parse_result_free(p);
}
static void test_seq_index_path(void) {
HArena *arena = h_new_arena(&system_allocator, 0);
HParsedToken *seq = h_make_seqn(arena, 1);
HParsedToken *seq2 = h_make_seqn(arena, 2);
HParsedToken *tok1 = h_make_uint(arena, 41);
HParsedToken *tok2 = h_make_uint(arena, 42);
seq->seq->elements[0] = seq2;
seq->seq->used = 1;
seq2->seq->elements[0] = tok1;
seq2->seq->elements[1] = tok2;
seq2->seq->used = 2;
g_check_cmp_int(h_seq_index_path(seq, 0, -1)->token_type, ==, TT_SEQUENCE);
g_check_cmp_int(h_seq_index_path(seq, 0, 0, -1)->token_type, ==, TT_UINT);
g_check_cmp_int64(h_seq_index_path(seq, 0, 0, -1)->uint, ==, 41);
g_check_cmp_int64(h_seq_index_path(seq, 0, 1, -1)->uint, ==, 42);
}
void register_regression_tests(void) {
g_test_add_func("/core/regression/bug118", test_bug118);
g_test_add_func("/core/regression/seq_index_path", test_seq_index_path);
}