Skip to content

Commit 73e5cc0

Browse files
committed
tests: output all state alignments in test_state_align
1 parent eabbe5c commit 73e5cc0

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
1212
set(PACKAGE_TARNAME "${PROJECT_SHORTNAME}-${PROJECT_VERSION}")
1313
set(PACKAGE_URL ${PROJECT_HOMEPAGE_URL})
1414
set(PACKAGE_BUGREPORT dhdaines@gmail.com)
15+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1516

1617
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
1718
include(CTest)

test/unit/test_state_align.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
/* -*- c-basic-offset: 4 -*- */
32
#include <pocketsphinx.h>
43

4+
#include "pocketsphinx/alignment.h"
55
#include "ps_alignment_internal.h"
66
#include "state_align_search.h"
77
#include "pocketsphinx_internal.h"
@@ -77,11 +77,27 @@ main(int argc, char *argv[])
7777

7878
for (itor = ps_alignment_words(al); itor;
7979
itor = ps_alignment_iter_next(itor)) {
80-
ps_alignment_entry_t *ent = ps_alignment_iter_get(itor);
80+
int start, duration, score;
81+
ps_alignment_iter_t *pitor;
8182

83+
score = ps_alignment_iter_seg(itor, &start, &duration);
84+
(void) score;
8285
printf("%s %d %d\n",
83-
dict_wordstr(dict, ent->id.wid),
84-
ent->start, ent->duration);
86+
ps_alignment_iter_name(itor),
87+
start, duration);
88+
for (pitor = ps_alignment_iter_children(itor); pitor; pitor = ps_alignment_iter_next(pitor)) {
89+
score = ps_alignment_iter_seg(pitor, &start, &duration);
90+
ps_alignment_iter_t *sitor;
91+
printf(" %s %d %d\n",
92+
ps_alignment_iter_name(pitor),
93+
start, duration);
94+
for (sitor = ps_alignment_iter_children(pitor); sitor;
95+
sitor = ps_alignment_iter_next(sitor)) {
96+
score = ps_alignment_iter_seg(sitor, &start, &duration);
97+
printf(" %s %d %d\n", ps_alignment_iter_name(sitor), start,
98+
duration);
99+
}
100+
}
85101
}
86102
itor = ps_alignment_words(al);
87103
TEST_EQUAL(ps_alignment_iter_get(itor)->start, 0);

0 commit comments

Comments
 (0)