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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#
# Tests for functions defined in src/strinobj.c
#
gap> START_TEST("kernel/strinobj.tst");
#
gap> s := EmptyString(2);
""
gap> EmptyString(-1);
Error, EmptyString: <len> must be a non-negative small integer (not the intege\
r -1)
#
gap> ShrinkAllocationString(s);
gap> ShrinkAllocationString(1);
Error, ShrinkAllocationString: <str> must be a string (not the integer 1)
#
gap> CHAR_INT(fail);
Error, CHAR_INT: <val> must be an integer between 0 and 255 (not the value 'fa\
il')
gap> CHAR_INT(-1);
Error, CHAR_INT: <val> must be an integer between 0 and 255 (not the integer -\
1)
gap> CHAR_INT(65);
'A'
#
gap> INT_CHAR(1);
Error, INT_CHAR: <val> must be a character (not the integer 1)
gap> INT_CHAR('A');
65
#
gap> CHAR_SINT(fail);
Error, CHAR_SINT: <val> must be an integer between -128 and 127 (not the value\
'fail')
gap> CHAR_SINT(255);
Error, CHAR_SINT: <val> must be an integer between -128 and 127 (not the integ\
er 255)
gap> CHAR_SINT(65);
'A'
#
gap> SINT_CHAR(1);
Error, SINT_CHAR: <val> must be a character (not the integer 1)
gap> SINT_CHAR('A');
65
#
gap> INTLIST_STRING("ABC", 1);
[ 65, 66, 67 ]
gap> INTLIST_STRING("ABC", -1);
[ 65, 66, 67 ]
gap> INTLIST_STRING(1, -1);
Error, INTLIST_STRING: <val> must be a string (not the integer 1)
#
gap> SINTLIST_STRING("ABC");
[ 65, 66, 67 ]
gap> SINTLIST_STRING(1);
Error, SINTLIST_STRING: <val> must be a string (not the integer 1)
#
gap> STRING_SINTLIST([ 65, 66, 67 ]);
"ABC"
gap> STRING_SINTLIST([ 65 .. 67 ]);
"ABC"
gap> STRING_SINTLIST(1);
Error, STRING_SINTLIST: <val> must be a plain list of small integers or a rang\
e (not the integer 1)
gap> STRING_SINTLIST([ 'B' ]);
Error, STRING_SINTLIST: <val> must be a plain list of small integers or a rang\
e (not a homogeneous plain list)
#
gap> REVNEG_STRING(1);
Error, REVNEG_STRING: <val> must be a string (not the integer 1)
#
# TypeString
#
# Verify that sorted strings remember their sorting status
gap> s:="abc";
"abc"
gap> HasIsSSortedList(s);
false
gap> IsSSortedList(s);
true
gap> TNAM_OBJ(s);
"list (string,ssort)"
gap> HasIsSSortedList(s);
true
# Verify that unsorted strings remember their sorting status
gap> s:="cba";
"cba"
gap> HasIsSSortedList(s);
false
gap> IsSSortedList(s);
false
gap> TNAM_OBJ(s);
"list (string,nsort)"
gap> HasIsSSortedList(s);
true
#
gap> CONV_STRING(1);
Error, CONV_STRING: <string> must be a string (not the integer 1)
#
gap> COPY_TO_STRING_REP(1);
Error, COPY_TO_STRING_REP: <string> must be a string (not the integer 1)
#
gap> POSITION_SUBSTRING("abc","x",0);
fail
gap> POSITION_SUBSTRING("abc","b",0);
2
gap> POSITION_SUBSTRING("abc","b",3);
fail
gap> POSITION_SUBSTRING(1,2,3);
Error, POSITION_SUBSTRING: <string> must be a string (not the integer 1)
gap> POSITION_SUBSTRING("abc",2,3);
Error, POSITION_SUBSTRING: <substr> must be a string (not the integer 2)
gap> POSITION_SUBSTRING("abc","b",-1);
Error, POSITION_SUBSTRING: <off> must be a non-negative small integer (not the\
integer -1)
#
gap> s:=" abc\n xyz\n";; NormalizeWhitespace(s); s;
"abc xyz"
gap> NormalizeWhitespace(1);
Error, NormalizeWhitespace: <string> must be a string (not the integer 1)
#
gap> s:="abcdabcd";; REMOVE_CHARACTERS(s, "db"); s;
"acac"
gap> REMOVE_CHARACTERS(1,1);
Error, REMOVE_CHARACTERS: <string> must be a string (not the integer 1)
gap> REMOVE_CHARACTERS(s,1);
Error, REMOVE_CHARACTERS: <rem> must be a string (not the integer 1)
#
gap> s:="abc";; TranslateString(s,UPPERCASETRANSTABLE); s;
"ABC"
gap> TranslateString(1,1);
Error, TranslateString: <string> must be a string (not the integer 1)
gap> TranslateString("abc",1);
Error, TranslateString: <trans> must be a string (not the integer 1)
gap> TranslateString("abc","def");
Error, TranslateString: <trans> must have length >= 256
#
gap> STOP_TEST("kernel/strinobj.tst");
|