PageRenderTime 25ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Examples/test-suite/d/long_long_runme.1.d

#
D | 35 lines | 29 code | 5 blank | 1 comment | 4 complexity | 8687d9eb0e378fb850bebfbcf6b50efa MD5 | raw file
 1// Checks if the long long and unsigned long long types work.
 2module long_long_runme;
 3
 4import Integer = tango.text.convert.Integer;
 5import long_long.long_long;
 6
 7void main() {
 8  check_ll(0L);
 9  check_ll(0x7FFFFFFFFFFFFFFFL);
10  check_ll(-10L);
11
12  check_ull(0u);
13  check_ull(127u);
14  check_ull(128u);
15  check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL
16  check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL
17}
18
19void check_ll(long value) {
20  ll = value;
21  long value_check = ll;
22  if (value != value_check) {
23    throw new Exception("Runtime test using long long failed: expected: " ~
24      Integer.toString(value) ~ ", got: " ~ Integer.toString(value_check));
25  }
26}
27
28void check_ull(ulong value) {
29  ull = value;
30  ulong value_check = ull;
31  if (value != value_check) {
32    throw new Exception( "Runtime test using unsigned long long failed: expected: " ~
33      Integer.toString(value) ~ ", ll_check=" ~ Integer.toString(value_check));
34  }
35}