1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/*
* $Id: test_thrend.c,v 1.4 2005/03/15 13:11:14 thep Exp $
* test_thrend.c : Test suite for <thai/thrend.h> functions
* Created: 2001-08-10
* Author: Theppitak Karoonboonyanan
*/
#include <thai/thrend.h>
#include <string.h>
#include <stdio.h>
static const thchar_t test_msg[] = "ͻذحءӻӡӻӻա͡";
static const thchar_t ans_tis[] = "ͻذحءһҡһһ\xdd\xddա͡";
static const thchar_t ans_tis_nd[] = "ͻذحءӻӡӻӻ\xdd\xddա͡";
static const thglyph_t ans_win_nd[] = "\x8bͻ\x86\x82\x9b\xfc\x80\x90ءӻӡ\x8cӻ\x87ӻ\xdd\x8c\x8b\xddա\x9a͡";
static const thglyph_t ans_win[] = "\x8bͻ\x86\x82\x9b\xfc\x80\x90ءһ\x99ҡһ\x99\x9cһ\x99\xdd\x8c\x8b\xddա\x9a͡";
static const thglyph_t ans_mac_nd[] = "\x88ͻ\x83\x95\x98\xfc\x80\x90ءӻӡ\x89ӻ\x84ӻ\xdd\x89\x88\xddա\x93͡";
static const thglyph_t ans_mac[] = "\x88ͻ\x83\x95\x98\xfc\x80\x90ءһ\x8fҡһ\x8f\x99һ\x8f\xdd\x89\x88\xddա\x93͡";
int test_th_render_tis()
{
thglyph_t rend_buff[80];
int err_no = 0;
fprintf(stderr, "Testing th_render_text_tis() w/o decomposing SARA AM\n");
th_render_text_tis(test_msg, rend_buff, sizeof rend_buff, 0);
if (strcmp((const char*)rend_buff, (const char*)ans_tis_nd) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_tis_nd);
++err_no;
}
fprintf(stderr, "Testing th_render_text_tis() decomposing SARA AM\n");
th_render_text_tis(test_msg, rend_buff, sizeof rend_buff, 1);
if (strcmp((const char*)rend_buff, (const char*)ans_tis) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_tis);
++err_no;
}
return err_no;
}
int test_th_render_win()
{
thglyph_t rend_buff[80];
int err_no = 0;
fprintf(stderr, "Testing th_render_text_win() w/o decomposing SARA AM\n");
th_render_text_win(test_msg, rend_buff, sizeof rend_buff, 0);
if (strcmp((const char*)rend_buff, (const char*)ans_win_nd) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_win_nd);
++err_no;
}
fprintf(stderr, "Testing th_render_text_win() decomposing SARA AM\n");
th_render_text_win(test_msg, rend_buff, sizeof rend_buff, 1);
if (strcmp((const char*)rend_buff, (const char*)ans_win) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_win);
++err_no;
}
return err_no;
}
int test_th_render_mac()
{
thglyph_t rend_buff[80];
int err_no = 0;
fprintf(stderr, "Testing th_render_text_mac() w/o decomposing SARA AM\n");
th_render_text_mac(test_msg, rend_buff, sizeof rend_buff, 0);
if (strcmp((const char*)rend_buff, (const char*)ans_mac_nd) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_mac_nd);
++err_no;
}
fprintf(stderr, "Testing th_render_text_mac() decomposing SARA AM\n");
th_render_text_mac(test_msg, rend_buff, sizeof rend_buff, 1);
if (strcmp((const char*)rend_buff, (const char*)ans_mac) != 0) {
fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_mac);
++err_no;
}
return err_no;
}
int main()
{
int err_no = 0;
err_no += test_th_render_tis();
err_no += test_th_render_win();
err_no += test_th_render_mac();
return err_no;
}
|