PageRenderTime 35ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/test/lib/numeric/natural/test_natural3.e

http://github.com/tybor/Liberty
Specman e | 199 lines | 147 code | 50 blank | 2 comment | 0 complexity | 9974e5a0196e44f1b5b9522655187654 MD5 | raw file
  1class TEST_NATURAL3
  2   
  3inherit
  4   EIFFELTEST_TOOLS
  5
  6create {}
  7   main
  8
  9feature {}
 10   main
 11      local
 12         a8: NATURAL_8; a16: NATURAL_16; a64: NATURAL_64
 13      do
 14         a8 := 4.to_natural_8
 15
 16         assert(1.to_natural_8 + 1.to_natural_8 + 1.to_natural_8 + 1.to_natural_8 = a8)
 17
 18         assert(a8 + 0.to_natural_8 = a8)
 19
 20         assert(0.to_natural_8.hexadecimal_digit = '0')
 21         assert(1.to_natural_8.hexadecimal_digit = '1')
 22         assert(2.to_natural_8.hexadecimal_digit = '2')
 23         assert(3.to_natural_8.hexadecimal_digit = '3')
 24         assert(4.to_natural_8.hexadecimal_digit = '4')
 25         assert(9.to_natural_8.hexadecimal_digit = '9')
 26         assert(10.to_natural_8.hexadecimal_digit = 'A')
 27         assert(11.to_natural_8.hexadecimal_digit = 'B')
 28         assert(15.to_natural_8.hexadecimal_digit = 'F')
 29
 30         assert(0.to_natural_8.decimal_digit = '0')
 31         assert(1.to_natural_8.decimal_digit = '1')
 32         assert(2.to_natural_8.decimal_digit = '2')
 33         assert(3.to_natural_8.decimal_digit = '3')
 34         assert(4.to_natural_8.decimal_digit = '4')
 35         assert(9.to_natural_8.decimal_digit = '9')
 36
 37         assert(0.to_natural_8.to_number.to_integer_32 = 0)
 38         assert(255.to_natural_8.to_number.to_integer_32 = 255)
 39
 40         assert(32.to_natural_8.to_character = ' ')
 41         
 42         assert(2.to_natural_8.is_even)
 43         assert(1.to_natural_8.is_odd)
 44
 45         assert(0.to_natural_8.to_string.is_equal("0"))
 46         assert(255.to_natural_8.to_string.is_equal("255"))         
 47
 48         assert(0.to_natural_8.to_unicode_string.is_equal(U"0"))
 49         assert(255.to_natural_8.to_unicode_string.is_equal(U"255"))
 50
 51         assert(0.to_natural_8.to_integer_8.to_natural_8  = 0.to_natural_8)
 52         assert(0.to_natural_8.to_integer_16.to_natural_8 = 0.to_natural_8)
 53         assert(0.to_natural_8.to_integer_32.to_natural_8 = 0.to_natural_8)
 54         assert(0.to_natural_8.to_integer_64.to_natural_8 = 0.to_natural_8)
 55
 56         assert(1.to_natural_8.to_integer_8.to_natural_8  = 1.to_natural_8)
 57         assert(1.to_natural_8.to_integer_16.to_natural_8 = 1.to_natural_8)
 58         assert(1.to_natural_8.to_integer_32.to_natural_8 = 1.to_natural_8)
 59         assert(1.to_natural_8.to_integer_64.to_natural_8 = 1.to_natural_8)
 60
 61         assert(127.to_natural_8.to_integer_8.to_natural_8  = 127.to_natural_8)
 62         assert(255.to_natural_8.to_integer_16.to_natural_8 = 255.to_natural_8)
 63         assert(255.to_natural_8.to_integer_32.to_natural_8 = 255.to_natural_8)
 64         assert(255.to_natural_8.to_integer_64.to_natural_8 = 255.to_natural_8)
 65
 66         assert(0.to_natural_8 < 255.to_natural_8)
 67         assert(0.to_natural_8 <= 255.to_natural_8)
 68         assert(255.to_natural_8 <= 255.to_natural_8)
 69         
 70         
 71         assert(255.to_natural_8 > 0.to_natural_8)
 72         assert(255.to_natural_8 >= 0.to_natural_8)
 73         assert(255.to_natural_8 >= 255.to_natural_8)
 74         
 75         -- -------------------------------------------------------------
 76         a16 := 4.to_natural_16
 77
 78         assert(1.to_natural_16 + 1.to_natural_16 + 1.to_natural_16 + 1.to_natural_16 = a16)
 79
 80         assert(a16 + 0.to_natural_16 = a16)
 81
 82         assert(0.to_natural_16.hexadecimal_digit = '0')
 83         assert(1.to_natural_16.hexadecimal_digit = '1')
 84         assert(2.to_natural_16.hexadecimal_digit = '2')
 85         assert(3.to_natural_16.hexadecimal_digit = '3')
 86         assert(4.to_natural_16.hexadecimal_digit = '4')
 87         assert(9.to_natural_16.hexadecimal_digit = '9')
 88         assert(10.to_natural_16.hexadecimal_digit = 'A')
 89         assert(11.to_natural_16.hexadecimal_digit = 'B')
 90         assert(15.to_natural_16.hexadecimal_digit = 'F')
 91
 92         assert(0.to_natural_16.decimal_digit = '0')
 93         assert(1.to_natural_16.decimal_digit = '1')
 94         assert(2.to_natural_16.decimal_digit = '2')
 95         assert(3.to_natural_16.decimal_digit = '3')
 96         assert(4.to_natural_16.decimal_digit = '4')
 97         assert(9.to_natural_16.decimal_digit = '9')
 98
 99         assert(0.to_natural_16.to_number.to_integer_32 = 0)
100         assert(255.to_natural_16.to_number.to_integer_32 = 255)
101
102         assert(32.to_natural_16.to_character = ' ')
103         
104         assert(2.to_natural_16.is_even)
105         assert(1.to_natural_16.is_odd)
106
107         assert(0.to_natural_16.to_string.is_equal("0"))
108         assert(255.to_natural_16.to_string.is_equal("255"))         
109
110         assert(0.to_natural_16.to_unicode_string.is_equal(U"0"))
111         assert(255.to_natural_16.to_unicode_string.is_equal(U"255"))
112
113         assert(0.to_natural_16.to_integer_8.to_natural_16  = 0.to_natural_16)
114         assert(0.to_natural_16.to_integer_16.to_natural_16 = 0.to_natural_16)
115         assert(0.to_natural_16.to_integer_32.to_natural_16 = 0.to_natural_16)
116         assert(0.to_natural_16.to_integer_64.to_natural_16 = 0.to_natural_16)
117
118         assert(1.to_natural_16.to_integer_8.to_natural_16  = 1.to_natural_16)
119         assert(1.to_natural_16.to_integer_16.to_natural_16 = 1.to_natural_16)
120         assert(1.to_natural_16.to_integer_32.to_natural_16 = 1.to_natural_16)
121         assert(1.to_natural_16.to_integer_64.to_natural_16 = 1.to_natural_16)
122
123         assert(127.to_natural_16.to_integer_8.to_natural_16  = 127.to_natural_16)
124         assert(255.to_natural_16.to_integer_16.to_natural_16 = 255.to_natural_16)
125         assert(255.to_natural_16.to_integer_32.to_natural_16 = 255.to_natural_16)
126         assert(255.to_natural_16.to_integer_64.to_natural_16 = 255.to_natural_16)
127
128         assert(0.to_natural_16 < 255.to_natural_16)
129         assert(0.to_natural_16 <= 255.to_natural_16)
130         assert(255.to_natural_16 <= 255.to_natural_16)
131         
132         
133         assert(255.to_natural_16 > 0.to_natural_16)
134         assert(255.to_natural_16 >= 0.to_natural_16)
135         assert(255.to_natural_16 >= 255.to_natural_16)
136         
137         -- -------------------------------------------------------------
138         a64 := 4.to_natural_64
139
140         assert(1.to_natural_64 + 1.to_natural_64 + 1.to_natural_64 + 1.to_natural_64 = a64)
141
142         assert(a64 + 0.to_natural_64 = a64)
143
144         assert(0.to_natural_64.hexadecimal_digit = '0')
145         assert(1.to_natural_64.hexadecimal_digit = '1')
146         assert(2.to_natural_64.hexadecimal_digit = '2')
147         assert(3.to_natural_64.hexadecimal_digit = '3')
148         assert(4.to_natural_64.hexadecimal_digit = '4')
149         assert(9.to_natural_64.hexadecimal_digit = '9')
150         assert(10.to_natural_64.hexadecimal_digit = 'A')
151         assert(11.to_natural_64.hexadecimal_digit = 'B')
152         assert(15.to_natural_64.hexadecimal_digit = 'F')
153
154         assert(0.to_natural_64.decimal_digit = '0')
155         assert(1.to_natural_64.decimal_digit = '1')
156         assert(2.to_natural_64.decimal_digit = '2')
157         assert(3.to_natural_64.decimal_digit = '3')
158         assert(4.to_natural_64.decimal_digit = '4')
159         assert(9.to_natural_64.decimal_digit = '9')
160
161         assert(0.to_natural_64.to_number.to_integer_32 = 0)
162         assert(255.to_natural_64.to_number.to_integer_32 = 255)
163
164         assert(32.to_natural_64.to_character = ' ')
165         
166         assert(2.to_natural_64.is_even)
167         assert(1.to_natural_64.is_odd)
168
169         assert(0.to_natural_64.to_string.is_equal("0"))
170         assert(255.to_natural_64.to_string.is_equal("255"))         
171
172         assert(0.to_natural_64.to_unicode_string.is_equal(U"0"))
173         assert(255.to_natural_64.to_unicode_string.is_equal(U"255"))
174
175         assert(0.to_natural_64.to_integer_8.to_natural_64  = 0.to_natural_64)
176         assert(0.to_natural_64.to_integer_64.to_natural_64 = 0.to_natural_64)
177         assert(0.to_natural_64.to_integer_32.to_natural_64 = 0.to_natural_64)
178         assert(0.to_natural_64.to_integer_64.to_natural_64 = 0.to_natural_64)
179
180         assert(1.to_natural_64.to_integer_8.to_natural_64  = 1.to_natural_64)
181         assert(1.to_natural_64.to_integer_64.to_natural_64 = 1.to_natural_64)
182         assert(1.to_natural_64.to_integer_32.to_natural_64 = 1.to_natural_64)
183         assert(1.to_natural_64.to_integer_64.to_natural_64 = 1.to_natural_64)
184
185         assert(127.to_natural_64.to_integer_8.to_natural_64  = 127.to_natural_64)
186         assert(255.to_natural_64.to_integer_64.to_natural_64 = 255.to_natural_64)
187         assert(255.to_natural_64.to_integer_32.to_natural_64 = 255.to_natural_64)
188         assert(255.to_natural_64.to_integer_64.to_natural_64 = 255.to_natural_64)
189
190         assert(0.to_natural_64 < 255.to_natural_64)
191         assert(0.to_natural_64 <= 255.to_natural_64)
192         assert(255.to_natural_64 <= 255.to_natural_64)
193         
194         
195         assert(255.to_natural_64 > 0.to_natural_64)
196         assert(255.to_natural_64 >= 0.to_natural_64)
197         assert(255.to_natural_64 >= 255.to_natural_64)
198      end
199end