home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** This software is Copyright (c) 1991 by Daniel Weaver. ** ** Permission is hereby granted to copy, distribute or otherwise ** use any part of this package as long as you do not try to make ** money from it or pretend that you wrote it. This copyright ** notice must be maintained in any copy made. ** ** Use of this software constitutes acceptance for use in an AS IS ** condition. There are NO warranties with regard to this software. ** In no event shall the author be liable for any damages whatsoever ** arising out of or in connection with the use or performance of this ** software. Any use of this software is at the user's own risk. ** ** If you make modifications to this software that you feel ** increases it usefulness for the rest of the community, please ** email the changes, enhancements, bug fixes as well as any and ** all ideas to me. This software is going to be maintained and ** enhanced as deemed necessary by the community. */ /* this module tests boolian flags and terminal modes */ #include "curses.h" #include "ted.h" static void uprint(s) char *s; { /* underline string for (ul) test */ if (s) while (*s) { put_str("_\b"); putchp(*s++); } } /* Note: uprint() sends underscore back-space character, and ucprint() sends character back-space underscore. */ static void ucprint(s) char *s; { /* underline string for (uc) test */ if (s) while (*s) { putchp(*s++); putchp('\b'); putp(underline_char); } } static void subtest_tbc() { /* test clear tabs (tbc) */ int i; put_clear(); putp(clear_all_tabs); ptext("Clear tabs (tbc)"); go_home(); put_crlf(); putchp('\t'); putchp('T'); go_home(); put_newlines(2); for (i = 1; i < columns; i++) { putchp('.'); } putchp('T'); go_home(); ptext("\n\n\nDone. (tbc)"); } static void subtest_hts() { /* set tabs with (hts), also (xt) glitch */ int i, tabat; put_clear(); tabat = init_tabs; if (set_tab) { ptext("Tabs set with (hts)"); put_crlf(); for (i = 1; i < columns; i++) { if (i % 8 == 1) putp(set_tab); putchp(' '); } tabat = 8; } else { ptext("(hts) not defined. The following tabs are set:"); } go_home(); put_newlines(2); if (tabat <= 0) tabat = 8; for (i = tabat; i < columns; i += tabat) { putchp('\t'); putchp('T'); } go_home(); put_newlines(3); for (i = 1; i < columns; i++) { putchp('.'); } go_home(); put_newlines(3); for (i = tabat; i < columns; i += tabat) { putchp('\t'); putchp('T'); } go_home(); put_newlines(4); putchp('.'); for (i = 2; i < columns; i++) { if (i % tabat == 1) putchp('T'); else putchp('.'); } go_home(); put_newlines(5); ptextln("The last two lines should be the same."); #if defined(SVR3) || defined(XENIX) if (!over_strike && (init_tabs > 0 || set_tab)) { ptextln("\nDestructive tab test"); ptext("(xt) should not "); put_cr(); ptext("(xt) should"); while (char_count < 16) { if (translate_mode && tab) putp(tab); else putp(TM_tab); char_count = ((char_count / tabat) + 1) * tabat; } putln("be set."); sprintf(temp, "(xt) is %s in the data base.", dest_tabs_magic_smso ? "true": "false"); ptextln(temp); } #endif } static void subtest_cbt() { /* test back tab (cbt) */ int i; if (back_tab) { put_clear(); ptext("Back tabs (cbt)"); go_home(); put_crlf(); for (i = 1; i < columns; i++) { putchp(' '); } for (i = 0; i < columns; i += 8) { putp(back_tab); putchp('T'); putp(back_tab); } go_home(); put_newlines(2); for (i = 1; i < columns; i++) { if (i % 8 == 1) putchp('T'); else putchp('.'); } go_home(); put_newlines(4); } else { if (init_tabs <= 0 && !set_tab) { /* setupterm() resets (cbt) if both (it) and (hts) are missing. */ ptextln("(it) and (hts) missing... (cbt) back tab not tested!"); } else ptextln("(cbt) back tab not present"); } } static void test_os_set() { /* test (am) (smam) (rmam) (xenl) on overstrike terminals */ int i, j; #if defined(SVR3) || defined(XENIX) if (exit_am_mode && can_go_home) { go_home(); putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am)"); } else ptext("(rmam) not present."); if (enter_am_mode && can_go_home) { go_home(); putp(enter_am_mode); ptext("\n\n\n(smam) will "); i = char_count; ptext("not set (am)"); go_home(); put_newlines(2); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); } else ptext("\n\n(smam) not present."); #endif if (can_go_home) { go_home(); ptext("\n\n\n\n\n(am) should "); i = char_count; ptext("not be set"); go_home(); put_newlines(4); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); go_home(); put_newlines(6); } else put_crlf(); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); ptext("\n(bw) should "); i = char_count; ptextln("not be set."); for (j = i; j < columns; j++) put_str("\b"); put_str("@@@"); put_crlf(); sprintf(temp, "(bw) is %s in the data base", auto_left_margin ? "true" : "false"); ptextln(temp); } static void subtest_os_xenl() { /* test (xenl) on overstrike terminals */ int i, j, k; if (can_go_home && can_clear_screen) { /* (xenl) test */ put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); ptext("\nreset (xenl). Does "); i = char_count; put_str("not ignore CR, does "); k = char_count; put_str("not ignore LF"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_cr(); for (j = 0; j < i; j++) putchp(' '); put_str("@@@\n@@"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); for (j = 0; j < k; j++) putchp(' '); put_str("@@@\r@@"); tty_set(); go_home(); put_newlines(4); } else ptextln("\n(xenl) not tested, (clear) (cup) or (home) missing"); sprintf(temp, "(xenl) is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } static void test_os_reset() { /* test (am) (smam) (rmam) (xenl) on non-overstrike terminals */ int i, j; #if defined(SVR3) || defined(XENIX) if (exit_am_mode && can_go_home) { go_home(); putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am) "); go_home(); put_str(" "); } else ptext("(rmam) not present."); if (enter_am_mode && can_go_home) { go_home(); putp(enter_am_mode); ptext("\n\n\n(smam) will not set (am)"); go_home(); put_newlines(2); for (j = 0; j < columns; j++) put_this(' '); ptext("(smam) will set (am) "); go_home(); put_str("\n\n "); } else ptext("\n\n(smam) not present."); #endif if (can_go_home) { go_home(); ptext("\n\n\n\n\n(am) should not be set"); go_home(); put_newlines(4); for (j = 0; j < columns; j++) put_this(' '); ptext("(am) should be set "); go_home(); put_str("\n\n\n\n \n\n"); } else put_crlf(); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); /* (ul) is used only if (os) is reset */ sprintf(temp, "\n(ul) is %s in the data base", transparent_underline ? "true" : "false"); ptextln(temp); sprintf(temp, "This text should %sbe underlined.", transparent_underline ? "" : "not "); uprint(temp); put_newlines(2); if (underline_char) { ptextln("Test underline character (uc)"); ucprint("This text should be underlined."); put_newlines(2); } else if (!enter_underline_mode) ptextln("(uc) underline character, is not defined\n"); ptextln("(bw) should not be set."); for (i = 12; i < columns; i++) put_str("\b"); if (delete_character) for (i = 0; i < 4; i++) putp(delete_character); else put_str(" "); put_crlf(); sprintf(temp, "(bw) is %s in the data base", auto_left_margin ? "true" : "false"); ptextln(temp); } static void subtest_xenl() { /* test (xenl) when (os) is reset */ int j; if (can_go_home) { /* (xenl) test */ put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); for (j = 0; j < columns; j++) put_this(' '); put_cr(); ptext("(xenl) should be set. Does not ignore CR"); go_home(); put_crlf(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); /* test (cud1) */ ptext("(xenl) should be set. Ignores (cud1)"); go_home(); put_newlines(3); if (scroll_forward && cursor_down && strcmp(scroll_forward, cursor_down)) { for (j = 0; j < columns; j++) put_this(' '); put_ind(); /* test (ind) */ ptext("(xenl) should be set. Ignores (ind)"); go_home(); put_newlines(5); } tty_set(); ptextln("If the above lines are blank then (xenl) should be false"); } else ptextln("(xenl) not tested, (clear) (cup) or (home) missing"); sprintf(temp, "(xenl) is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } test_mode() { int i, j; char *s; new_test(3); if (run_mode("(os)")) do { ptext("\n(os) should be true, not false."); put_cr(); ptextln("(os) should be false."); sprintf(temp, "(os) is %s in the data base", over_strike ? "true" : "false"); ptextln(temp); } while (repeat_test(FALSE)); if (run_mode("(smam)(rmam)(ul)(uc)(am)(bw)")) do { put_clear(); if (over_strike) test_os_set(); else test_os_reset(); } while (repeat_test(FALSE)); if (run_mode("(xenl)(eo)(xmc)(xhp)")) do { if (over_strike) subtest_os_xenl(); else subtest_xenl(); if (transparent_underline || over_strike || underline_char) { /* test (eo) */ sprintf(temp, "\n(eo) is %s in the data base", erase_overstrike ? "true" : "false"); ptextln(temp); ptext("(eo) should "); if (underline_char) ucprint("not"); else uprint("not"); put_cr(); ptextln("(eo) should be set"); } if (enter_standout_mode) { sprintf(temp, "\n(xmc) is %d", magic_cookie_glitch); ptextln(temp); j = magic_cookie_glitch * 8; for (i = 0; i < j; i++) put_str(" "); ptextln(" These two lines should line up."); if (j > 0) char_count += j; for (i = 0; i < 4; i++) { put_mode(enter_standout_mode); putchp(' '); put_mode(exit_standout_mode); putchp(' '); } ptextln("These two lines should line up."); /* test (xhp) */ put_crlf(); put_mode(enter_standout_mode); put_str("Stand out"); put_mode(exit_standout_mode); put_cr(); ptextln("If any part of this line is standout then (xhp) should be set."); sprintf(temp, "(xhp) is %s in the data base", ceol_standout_glitch ? "true" : "false"); ptextln(temp); } } while (repeat_test(FALSE)); if (run_test(cursor_address, "(mir) and (msgr) not tested because (cup) is missing", FALSE)) do { put_clear(); if (enter_insert_mode != (char *)0 & exit_insert_mode != (char *)0) { ptextln("If the block of X's are square then (mir) should be set. (smir) (rmir) (cup)"); i = line_count; put_str("\nXXX\nXXX\nXXX\nXXX"); putp(enter_insert_mode); s = tcup(cursor_address, i + 1, 0); tputs(s, lines, putch); putchp('x'); s = tcup(cursor_address, i + 2, 1); tputs(s, lines, putch); putchp('x'); s = tcup(cursor_address, i + 3, 2); tputs(s, lines, putch); putchp('x'); s = tcup(cursor_address, i + 4, 3); tputs(s, lines, putch); putchp('x'); putp(exit_insert_mode); put_crlf(); } else ptextln("(smir) (rmir) not present. (mir) not tested."); if ((enter_standout_mode && exit_standout_mode) || (enter_alt_charset_mode && exit_alt_charset_mode)) { put_crlf(); ptext("If you see a diagonal line of standout X's then (msgr) should be set, if any of the blanks are standout then (msgr) should be reset. (smacs) (rmacs) (cup)"); i = line_count + 1; tputs(tcup(cursor_address, i, 0), lines, putch); put_mode(enter_alt_charset_mode); put_crlf(); /* some versions of the wy-120 can not clear lines or screen when in alt charset mode. If (el) and (ed) are defined then I can test them. If they are not defined then they can not break (msgr) */ putp(clr_eos); putp(clr_eol); put_mode(exit_alt_charset_mode); put_mode(enter_standout_mode); putchp('X'); tputs(tcup(cursor_address, i + 2, 1), lines, putch); putchp('X'); tputs(tcup(cursor_address, i + 3, 2), lines, putch); putchp('X'); tputs(tcup(cursor_address, i + 4, 3), lines, putch); putchp('X'); put_mode(exit_standout_mode); put_crlf(); putp(clr_eos); /* OK if missing */ put_crlf(); } else ptextln("(smso) (rmso) (smacs) (rmacs) not present. (msgr) not tested."); sprintf(temp, "(mir) is %s and (msgr) is %s in the data base", move_insert_mode ? "true" : "false", move_standout_mode ? "true" : "false"); ptextln(temp); } while (repeat_test(FALSE)); if (run_test(clear_all_tabs, "Clear all tabs (tbc) not defined.", TRUE)) do { subtest_tbc(); } while (repeat_test(FALSE)); if (run_mode("(hts)(xt)")) do { subtest_hts(); } while (repeat_test(FALSE)); if (run_mode("(cbt)(in)")) do { subtest_cbt(); if (enter_insert_mode && exit_insert_mode) { /* test (in) */ ptextln("\nTesting (in) with (smir) and (rmir)"); putln("\tIf these two lines line up ..."); put_str("\tIf these two lines line up ..."); put_cr(); putp(enter_insert_mode); putchp(' '); putp(exit_insert_mode); ptext("\nthen (in) should be set. "); sprintf(temp, "(in) is %s in the data base.", insert_null_glitch ? "true" : "false"); ptextln(temp); } } while (repeat_test(FALSE)); if (run_mode("(da)(db)") && can_clear_screen && scroll_reverse && scroll_forward) do { /* test (da) and (db) */ put_clear(); if (scroll_reverse) ptext("(da) should be set\r"); move_to(0, 0, lines - 1, 0, 3); if (scroll_forward) ptext("(db) should be set\r"); putp(scroll_forward); move_to(lines - 1, 0, 0, 0, 3); putp(scroll_reverse); putp(scroll_reverse); move_to(0, 0, lines - 1, 0, 3); putp(scroll_forward); move_to(lines - 1, 0, 0, 0, 3); ptextln("\n\n\n\n\nIf the top line is blank then (da) should be false."); ptextln("If the bottom line is blank then (db) should be false."); sprintf(temp, "\n(da) is %s, and (db) is %s, in the data base.", memory_above ? "true" : "false", memory_below ? "true" : "false"); ptextln(temp); line_count = lines; } while (repeat_test(FALSE)); }