Debian Codegraph @

tests/backtranslation_emphasis.c

raw symbols SCIP
1 /* liblouis Braille Translation and Back-Translation Library
2
3 Copyright (C) 2025 Benedict Carling <[email protected]>
4
5 Copying and distribution of this file, with or without modification,
6 are permitted in any medium without royalty provided the copyright
7 notice and this notice are preserved. This file is offered as-is,
8 without any warranty. */
9
10 /* Minimal test that exercises lou_backTranslate with a typeform buffer.
11 * Full emphasis/typeform coverage lives in backtranslation_emphasis.yaml. */
12
13 #include <config.h>
14
15 #include <stdio.h>
16 #include <string.h>
17 #include <stdlib.h>
18 #include "liblouis.h"
19
20 int
21 main(int argc, char **argv)
22 {
23 const char *table = "tables/en-ueb-g1.ctb";
24 int result = 0;
25
26 /* "hello" in UEB - no emphasis indicators */
27 widechar input[] = { 0x2813, 0x2811, 0x2807, 0x2807, 0x2815 };
28 widechar outbuf[256];
29 formtype typeform[256];
30 int inlen = 5;
31 int outlen = 256;
32 int i;
33
34 memset(outbuf, 0, sizeof(outbuf));
35 memset(typeform, 0, sizeof(typeform));
36
37 if (!lou_backTranslate(table, input, &inlen, outbuf, &outlen, typeform, NULL,
38 NULL, NULL, NULL, 0)) {
39 printf("FAIL: lou_backTranslate returned failure\n");
40 result = 1;
41 goto cleanup;
42 }
43
44 /* Check output text */
45 {
46 const char *expected = "hello";
47 char output_str[256];
48 for (i = 0; i < outlen && i < 255; i++)
49 output_str[i] = (char)outbuf[i];
50 output_str[i] = '\0';
51
52 if (strcmp(output_str, expected) != 0) {
53 printf("FAIL: expected '%s', got '%s'\n", expected, output_str);
54 result = 1;
55 }
56 }
57
58 /* Verify typeform buffer is all zeros (no emphasis) */
59 for (i = 0; i < outlen; i++) {
60 if (typeform[i] != 0) {
61 printf("FAIL: typeform[%d] = %d, expected 0\n", i, typeform[i]);
62 result = 1;
63 break;
64 }
65 }
66
67 if (result == 0)
68 printf("PASS: backtranslation with typeform buffer\n");
69
70 cleanup:
71 lou_free();
72 return result;
73 }