/test/lib/string/test_character2.e
Specman e | 90 lines | 65 code | 4 blank | 21 comment | 1 complexity | 775640fca5a03ebaee83311343f319f9 MD5 | raw file
1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries. 2-- See the Copyright notice at the end of this file. 3-- 4class TEST_CHARACTER2 5 6insert 7 EIFFELTEST_TOOLS 8 9create {} 10 make 11 12feature {ANY} 13 make 14 local 15 str: STRING; c: CHARACTER; i, j: INTEGER 16 do 17 str := 0.to_character.to_hexadecimal 18 assert(("00").is_equal(str)) 19 str := 1.to_character.to_hexadecimal 20 assert(("01").is_equal(str)) 21 str := 254.to_character.to_hexadecimal 22 assert(("FE").is_equal(str)) 23 str := 255.to_character.to_hexadecimal 24 assert(("FF").is_equal(str)) 25 i := 0 26 c := i.to_character 27 assert(c.code = 0) 28 i := 1 29 c := i.to_character 30 assert(c.code = 1) 31 i := 127 32 c := i.to_character 33 assert(c.code = 127) 34 i := 128 35 c := i.to_character 36 assert(c.code = 128) 37 i := 254 38 c := i.to_character 39 assert(c.code = 254) 40 i := 255 41 c := i.to_character 42 assert(c.code = 255) 43 from 44 c := c.default 45 assert(c = '%U') 46 i := 0 47 until 48 i >= 255 49 loop 50 assert(i = c.code) 51 c := c.next 52 i := i + 1 53 end 54 from 55 c := c.default 56 assert(c = '%U') 57 i := 0 58 until 59 i >= 255 60 loop 61 j := c.to_integer_8 62 if i <= 127 then 63 assert(i = c.to_integer_8) 64 else 65 assert(i - 256 = c.to_integer_8) 66 end 67 c := c.next 68 i := i + 1 69 end 70 end 71 72end -- class TEST_CHARACTER2 73-- 74-- ------------------------------------------------------------------------------------------------------------------------------ 75-- Copyright notice below. Please read. 76-- 77-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 78-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 79-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 80-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 81-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 82-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 83-- 84-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 85-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 86-- 87-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 88-- 89-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 90-- ------------------------------------------------------------------------------------------------------------------------------