Ejemplo n.º 1
0
/* inserts "inst" before "where" ("inst" can be a chain of insts) */
void
instrlist_preinsert(instrlist_t *ilist, instr_t *where, instr_t *inst)
{
    instr_t *whereprev;
    instr_t *top = inst;
    instr_t *bot;

    if (where == NULL) {
        /* if where is NULL there is no inst to send for a "before" */
        instrlist_append(ilist, inst);
        return;
    }

    CLIENT_ASSERT(where != NULL, "instrlist_preinsert: where cannot be NULL");
    CLIENT_ASSERT(instr_get_prev(inst) == NULL,
                  "instrlist_preinsert: cannot add middle of list");
    whereprev = instr_get_prev(where);
    check_translation(ilist, inst);
    while (instr_get_next(inst)) {
        inst = instr_get_next(inst);
        check_translation(ilist, inst);
    }
    bot = inst;
    if (whereprev) {
        instr_set_next(whereprev, top);
        instr_set_prev(top, whereprev);
    } else {
        ilist->first = top;
    }
    instr_set_next(bot, where);
    instr_set_prev(where, bot);
}
Ejemplo n.º 2
0
/* inserts "inst" after "where" ("inst" can be a chain of insts) */
void
instrlist_postinsert(instrlist_t *ilist, instr_t *where, instr_t *inst)
{
    instr_t *wherenext;
    instr_t *top = inst;
    instr_t *bot;

    if (where == NULL) {
        /* if where is NULL there is no inst to send for an "after" */
        instrlist_prepend(ilist, inst);
        return;
    }

    CLIENT_ASSERT(where != NULL, "instrlist_postinsert: where cannot be NULL");
    CLIENT_ASSERT(instr_get_prev(inst) == NULL,
                  "instrlist_postinsert: cannot add middle of list");

    wherenext = instr_get_next(where);
    check_translation(ilist, inst);
    while (instr_get_next(inst)) {
        inst = instr_get_next(inst);
        check_translation(ilist, inst);
    }
    bot = inst;
    instr_set_next(where, top);
    instr_set_prev(top, where);
    if (wherenext) {
        instr_set_next(bot, wherenext);
        instr_set_prev(wherenext, bot);
    } else {
        ilist->last = bot;
    }
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{

  int result = 0;

  const char *text = "\\x280d\\x280e";  // "⠍⠎"
  const char *expected = "sm";  // "⠎⠍"

  result |= check_translation("letterDefTest_letter.ctb", text, NULL, expected);
  result |= check_translation("letterDefTest_lowercase.ctb", text, NULL, expected);
  result |= check_translation("letterDefTest_uplow.ctb", text, NULL, expected);
  result |= check_translation("letterDefTest_uppercase.ctb", text, NULL, expected);

  return result;
}
Ejemplo n.º 4
0
int
main(int argc, char **argv)
{

  const char* table = "pass2.ctb";
  int result = 0;

  /* First check a plain word to see if the table works */
  result = check_translation(table, "Rene", NULL, "rene");

  /* then try a word which uses pass2 */
  result |= check_translation(table, "Reno", NULL, "ren'o");

  return result;
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
  int result = 0;
  const char *text = "---.com";
  const char *expected = "";

  result |= check_translation("UEBC-g2.ctb", text, NULL, expected);

  lou_free();

  return result;
}
Ejemplo n.º 6
0
/* prepends inst to the list ("inst" can be a chain of insts) */
void
instrlist_prepend(instrlist_t *ilist, instr_t *inst)
{
    instr_t *top = inst;
    instr_t *bot;

    CLIENT_ASSERT(instr_get_prev(inst) == NULL,
                  "instrlist_prepend: cannot add middle of list");
    check_translation(ilist, inst);
    while (instr_get_next(inst)) {
        inst = instr_get_next(inst);
        check_translation(ilist, inst);
    }
    bot = inst;
    if (ilist->first) {
        instr_set_next(bot, ilist->first);
        instr_set_prev(ilist->first, bot);
        ilist->first = top;
    } else {
        ilist->first = top;
        ilist->last = bot;
    }
}
Ejemplo n.º 7
0
int
main(int argc, char **argv)
{

  int result = 0;

  const char *str      = "This is a Test";
  const char *typeform = "00000000000000";
  const char *expected = ",this is a ,test";

  result |= check_translation(TRANSLATION_TABLE, str, convert_typeform(typeform), expected);

  str      = "This is a Test in Italic.";
  typeform = "1111111111111111111111111";
  expected = "..,this is a ,test in ,italic4.'";

  result |= check_translation(TRANSLATION_TABLE, str, convert_typeform(typeform), expected);

  str      = "This is a Test";
  typeform = "00000111100000";
  expected = ",this .is .a ,test";

  result |= check_translation(TRANSLATION_TABLE, str, convert_typeform(typeform), expected);

  /* Test case requested here:
   * http://www.freelists.org/post/liblouis-liblouisxml/Mesar-here-are-some-test-possibilities */

  str      = "time and spirit";
  typeform = "111111111111111";
  expected = ".\"t .& ._s";

  result |= check_translation(TRANSLATION_TABLE, str, convert_typeform(typeform), expected);

  lou_free();
  return result;
}
Ejemplo n.º 8
0
int
main(int argc, char **argv)
{

  int result = 0;

  /* First check italics with the English table */
  const char *str      = "He said it wasn't always working as expected.";
  const formtype typeform[] = {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0};
  const char *expected = ".,he sd x wasn't .alw .\"w+ z expect$4";

  result |= check_translation(TRANSLATION_TABLE, str, typeform, expected);

  /* Then check a test table that defines lastworditalafter */
  str      = "Er sagte es funktioniere nicht immer wie erwartet.";
  const formtype typeform2[] = {1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  expected = "_ER SAGTE ES __FUNKTION0RE NI4T', IMMER W0 ERWARTET.";

  result |= check_translation("de-ch-g1.ctb", str, typeform2, expected);

  lou_free();

  return result;
}
Ejemplo n.º 9
0
int
main(int argc, char **argv)
{

  int result = 0;

  const char* txt = "Fussball-Vereinigung";

  const char* table = "inpos_match_replace.ctb";

  const char* brl = "FUSSBALL-V7EINIGUNG";

  const int inpos[] = {0,1,2,3,4,5,6,7,8,9,9,12,13,14,15,16,17,18,19};

  result |= check_translation(table, txt, NULL, brl);
  result |= check_inpos(table, txt, inpos);

  return result;

}
Ejemplo n.º 10
0
int
main(int argc, char **argv)
{
    int i;
    int result = 0;

    char* table = "pass0_typebuf.ctb";
    char* text = "foo baz";
    char* expected = "foobar .baz";
    char* typeform = malloc(20 * sizeof(char));
    for (i = 0; i < 7; i++)
      typeform[i] = 0;
    for (i = 4; i < 7; i++)
      typeform[i] = 1;

    result = check_translation(table, text, typeform, expected);

    lou_free();

    return result;
}
Ejemplo n.º 11
0
int main(int argc, char **argv)
{

  int i;
  int result = 0;

  const char *tests[] = {
    /* first column is the text, the second is the expected value */
    " ", " ",
    /* the usual case */
    "                                                                                ", " ",
    /* a very long string */
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                ", " ",
    /* an even longer string */
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                ", " ",
    /* a string containing tabs */
    "    \t",     " \t",
    "    \t    ", " \t ",
    "\t    ",     "\t ",
    /* Strings containing newlines */
    "    \n",     " \n",
    "    \n    ", " \n ",
    "\n    ",     "\n "
  };

  /* A number of strings that we want to squash, i.e. they should all
     result in an output of one space */
  const char *strings[] = {
    /* a simple space */
    " ",
    /* a long string */
    "                                                                                ",
    /* a very long string */
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                ",
    /* an even longer string */
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                " \
    "                                                                                ",
    /* a couple of strings containing tabs */
    "    \t",
    "    \t    ",
    "\t    ",
    /* Strings containing newlines */
    "    \n",
    "    \n    ",
    "\n    ",
    /* All mixed */
    "    \n    \t    \n    \t\t    \n\n\n\t\t    ",
  };
  const char *expected = " ";

  int tests_len = sizeof(tests)/sizeof(char*);

  for (i = 0; i < tests_len; i += 2)
    result |= check_translation("tests/tables/squash_space_with_repeated.utb", tests[i], NULL, tests[i+1]);

  tests_len = sizeof(strings)/sizeof(char*);

  for (i = 0; i < tests_len; i++)
    result |= check_translation("tests/tables/squash_space_with_correct.utb", strings[i], NULL, expected);

  for (i = 0; i < tests_len; i++)
    result |= check_translation("tests/tables/squash_space_with_context_1.utb", strings[i], NULL, expected);

  for (i = 0; i < tests_len; i++)
    result |= check_translation("tests/tables/squash_space_with_context_2.utb", strings[i], NULL, expected);

  lou_free();

  return result;
}