/test/lib/numeric/integer/test_to_hexadecimal.e
Specman e | 156 lines | 127 code | 5 blank | 24 comment | 1 complexity | 102a0c6830e0e20a16e0306a55872027 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_TO_HEXADECIMAL 5 6create {} 7 make 8 9feature {ANY} 10 make 11 local 12 i8: INTEGER_8; i16: INTEGER_16; i32: INTEGER_32; i64: INTEGER_64; view: STRING 13 do 14 i8 := 0 15 assert(i8.hexadecimal_digit = '0') 16 assert(0.hexadecimal_digit = '0') 17 i8 := 1 18 assert(i8.hexadecimal_digit = '1') 19 assert(1.hexadecimal_digit = '1') 20 i8 := 8 21 assert(i8.hexadecimal_digit = '8') 22 assert(8.hexadecimal_digit = '8') 23 i8 := 9 24 assert(i8.hexadecimal_digit = '9') 25 assert(9.hexadecimal_digit = '9') 26 i8 := 10 27 assert(i8.hexadecimal_digit = 'A') 28 assert(10.hexadecimal_digit = 'A') 29 i8 := 15 30 assert(i8.hexadecimal_digit = 'F') 31 assert(15.hexadecimal_digit = 'F') 32 -- ------------------------------------- 33 i8 := -128 34 view := i8.to_hexadecimal 35 assert(("80").is_equal(view)) 36 i8 := -127 37 view := i8.to_hexadecimal 38 assert(("81").is_equal(view)) 39 i8 := -2 40 view := i8.to_hexadecimal 41 assert(("FE").is_equal(view)) 42 i8 := -1 43 view := i8.to_hexadecimal 44 assert(("FF").is_equal(view)) 45 i8 := 0 46 view := i8.to_hexadecimal 47 assert(("00").is_equal(view)) 48 i8 := 1 49 view := i8.to_hexadecimal 50 assert(("01").is_equal(view)) 51 i8 := 2 52 view := i8.to_hexadecimal 53 assert(("02").is_equal(view)) 54 i8 := 126 55 view := i8.to_hexadecimal 56 assert(("7E").is_equal(view)) 57 i8 := 127 58 view := i8.to_hexadecimal 59 assert(("7F").is_equal(view)) 60 -- ------------------------------------- 61 i16 := -32768 62 view := i16.to_hexadecimal 63 assert(("8000").is_equal(view)) 64 i16 := -32767 65 view := i16.to_hexadecimal 66 assert(("8001").is_equal(view)) 67 i16 := -2 68 view := i16.to_hexadecimal 69 assert(("FFFE").is_equal(view)) 70 i16 := -1 71 view := i16.to_hexadecimal 72 assert(("FFFF").is_equal(view)) 73 i16 := 0 74 view := i16.to_hexadecimal 75 assert(("0000").is_equal(view)) 76 i16 := 1 77 view := i16.to_hexadecimal 78 assert(("0001").is_equal(view)) 79 i16 := 2 80 view := i16.to_hexadecimal 81 assert(("0002").is_equal(view)) 82 i16 := 32767 83 view := i16.to_hexadecimal 84 assert(("7FFF").is_equal(view)) 85 i16 := 32766 86 view := i16.to_hexadecimal 87 assert(("7FFE").is_equal(view)) 88 i32 := -2147483648 89 view := i32.to_hexadecimal 90 assert(("80000000").is_equal(view)) 91 i32 := -2147483647 92 view := i32.to_hexadecimal 93 assert(("80000001").is_equal(view)) 94 i32 := -2 95 view := i32.to_hexadecimal 96 assert(("FFFFFFFE").is_equal(view)) 97 i32 := -1 98 view := i32.to_hexadecimal 99 assert(("FFFFFFFF").is_equal(view)) 100 i32 := 0 101 view := i32.to_hexadecimal 102 assert(("00000000").is_equal(view)) 103 i32 := 1 104 view := i32.to_hexadecimal 105 assert(("00000001").is_equal(view)) 106 i32 := 2 107 view := i32.to_hexadecimal 108 assert(("00000002").is_equal(view)) 109 i32 := 2147483646 110 view := i32.to_hexadecimal 111 assert(("7FFFFFFE").is_equal(view)) 112 i32 := 2147483647 113 view := i32.to_hexadecimal 114 assert(("7FFFFFFF").is_equal(view)) 115 -- ------------------------------------- 116 i64 := -2147483649 117 view := i64.to_hexadecimal 118 assert(("FFFFFFFF7FFFFFFF").is_equal(view)) 119 i64 := 2147483648 120 view := i64.to_hexadecimal 121 assert(("0000000080000000").is_equal(view)) 122 end 123 124 assert (b: BOOLEAN) 125 do 126 cpt := cpt + 1 127 if not b then 128 sedb_breakpoint 129 std_output.put_string("TEST_TO_HEXADECIMAL: ERROR Test # ") 130 std_output.put_integer(cpt) 131 std_output.put_string("%N") 132 crash 133 end 134 end 135 136 cpt: INTEGER 137 138end -- class TEST_TO_HEXADECIMAL 139-- 140-- ------------------------------------------------------------------------------------------------------------------------------ 141-- Copyright notice below. Please read. 142-- 143-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 144-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 145-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 146-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 147-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 148-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 149-- 150-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 151-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 152-- 153-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 154-- 155-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 156-- ------------------------------------------------------------------------------------------------------------------------------