| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
} |