PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/numeric/natural/test_natural5.e

http://github.com/tybor/Liberty
Specman e | 76 lines | 57 code | 16 blank | 3 comment | 0 complexity | 10bba036e88b070f88c3789d72427e06 MD5 | raw file
 1class TEST_NATURAL5
 2--
 3-- Added to_real_* tests.
 4--
 5inherit
 6   EIFFELTEST_TOOLS
 7
 8create {}
 9   main
10
11feature {}
12   main
13      local
14         n8: NATURAL_8; n16: NATURAL_16; n32: NATURAL_32; n64: NATURAL_64
15         r32: REAL_32; r64: REAL_64
16      do
17         n8 := 1.to_natural_8
18         r32 := n8.to_real_32
19         assert(r32.to_string.has_prefix("1.0"))
20         
21         n8 := 2.to_natural_8
22         r64 := n8.to_real_64
23         assert(r64.to_string.has_prefix("2.0"))
24
25         n16 := 3.to_natural_16
26         r32 := n16.to_real_32
27         assert(r32.to_string.has_prefix("3.0"))
28         
29         n16 := 4.to_natural_16
30         r64 := n16.to_real_64
31         assert(r64.to_string.has_prefix("4.0"))
32         
33         n32 := 5.to_natural_32
34         r32 := n32.to_real_32
35         assert(r32.to_string.has_prefix("5.0"))
36         
37         n32 := 6.to_natural_32
38         r64 := n32.to_real_64
39         assert(r64.to_string.has_prefix("6.0"))
40
41         n64 := 7.to_natural_64
42         r32 := n64.to_real_32
43         assert(r32.to_string.has_prefix("7.0"))
44
45         n64 := 8.to_natural_64
46         r64 := n64.to_real_64
47         assert(r64.to_string.has_prefix("8.0"))
48         
49
50         n64 := 10.to_natural_64
51         assert(n64.to_natural_32 = 10.to_natural_32)
52         assert(n64.to_natural_16 = 10.to_natural_16)
53         assert(n64.to_natural_8 = 10.to_natural_8)
54
55         n32 := 11.to_natural_32
56         assert(n32.to_natural_64 = 11.to_natural_64)
57         assert(n32.to_natural_16 = 11.to_natural_16)
58         assert(n32.to_natural_8 = 11.to_natural_8)
59         
60         n16 := 12.to_natural_16
61         assert(n16.to_natural_64 = 12.to_natural_64)
62         assert(n16.to_natural_32 = 12.to_natural_32)
63         assert(n16.to_natural_8 = 12.to_natural_8)
64         
65         n8 := 13.to_natural_8
66         assert(n8.to_natural_64 = 13.to_natural_64)
67         assert(n8.to_natural_32 = 13.to_natural_32)
68         assert(n8.to_natural_16 = 13.to_natural_16)
69
70         assert(14.to_natural_8.to_number.to_string.is_equal("14"))
71         assert(14.to_natural_16.to_number.to_string.is_equal("14"))
72         assert(14.to_natural_32.to_number.to_string.is_equal("14"))
73         assert(14.to_natural_64.to_number.to_string.is_equal("14"))
74
75      end
76end