char.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
class TEST_CHAR
class TEST_CHAR is
-- This is a test program to test the internationalised class CHAR.
-- Note that it is not portable for simplicity in building a local library.
-- Version 1.0 Nov 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 19 Nov 97 kh Original
include TEST ;
test_chars is
-- This routine tests the character class which has a bit-pattern which
-- may be converted into any encoding.
class_name("CHAR") ;
lib : LIBCHARS := LIBCHARS::default ;
control_ch : CHAR := CHAR::create(CONTROL_CODES::BACKSPACE,lib) ;
test("is_print",control_ch.is_print.str,false.str) ;
test("is_control",control_ch.is_control.str,true.str) ;
test("is_space",control_ch.is_space.str,true.str) ;
space_ch : CHAR := lib.Space.char ;
test("is_print",space_ch.is_print.str,true.str) ;
test("is_control",space_ch.is_control.str,false.str) ;
test("is_space",space_ch.is_space.str,true.str) ;
test("equals", (control_ch = space_ch).str, false.str) ;
test("equals", (lib.Space.char = space_ch).str,true.str) ;
test("less than", (control_ch < space_ch).str, true.str) ;
num_ch : CHAR := lib.digit(9).char ;
test("is_numeric", num_ch.is_numeric.str, true.str) ;
test("is_digit", num_ch.is_digit.str, true.str) ;
test("is_hex_digit", num_ch.is_hex_digit.str, true.str) ;
test("is_octal_digit", num_ch.is_octal_digit.str, false.str) ;
test("digit_value", num_ch.digit_value.str,9.str) ;
test("hex_digit_value", num_ch.hex_digit_value.str,9.str) ;
lower_ch : CHAR := 'f' ;
upper_ch : CHAR := 'F' ;
test("is_alpha",upper_ch.is_alpha.str,true.str) ;
test("is_alpha",lower_ch.is_alpha.str,true.str) ;
test("lower",upper_ch.lower.str,lower_ch.str) ;
test("upper",lower_ch.upper.str,upper_ch.str) ;
test("is_alpha",upper_ch.is_punct.str,false.str) ;
test("hash",(upper_ch.hash = lower_ch.hash).str,false.str) ;
built_ch : CHAR := CHAR::build(upper_ch.code.raw_binstr.cursor,lib) ;
test("build", built_ch.str,upper_ch.str) ;
stop_ch : CHAR := lib.Fullstop.char ;
test("is_punct",stop_ch.is_punct.str,true.str) ;
test("str",stop_ch.str.str,stop_ch.str) ;
cult_path : FILE_PATH := CULTURE::default.resource_path.head ;
loc_path : FILE_PATH := cult_path.append("default").append(
"bin").append("culture") ;
unchecked_test("new culture", loc_path.str,"OK?") ;
new_cult : CULTURE := CULTURE::create(loc_path) ;
test("convert " + stop_ch.code.card.hex_str,
(stop_ch.convert(new_cult.sather_lib).code = stop_ch.code).str,
true.str) ;
finish
end ;
main is
test_chars
end ;
end ; -- TEST_CHAR