Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / IDLv4 / explicit_ints / main.cpp
blob43ff6583975e2e93e6d081fa7ee527f35a346f38
1 #include "testC.h"
3 #include "tao/idl_features.h"
4 #ifdef TAO_IDL_HAS_EXPLICIT_INTS
5 # if !TAO_IDL_HAS_EXPLICIT_INTS
6 # error "Expecting macro to be true"
7 # endif
8 #else
9 # error "Expecting macro to be defined"
10 #endif
12 #include "ace/OS_NS_stdlib.h"
13 #include "ace/OS_main.h"
14 #include "ace/streams.h"
16 namespace stream8 {
17 std::ostream &
18 operator<< (std::ostream &os, CORBA::UInt8 value) {
19 return os << static_cast<unsigned>(value);
22 std::ostream &
23 operator<< (std::ostream &os, CORBA::Int8 value) {
24 return os << static_cast<int>(value);
28 template <typename IntType>
29 void
30 expect_equals (bool &any_failed, const char *name, IntType actual, IntType expected)
32 if (actual != expected)
34 using stream8::operator<<;
35 *ACE_DEFAULT_LOG_STREAM
36 << "ERROR: For " << name << " expected: " << expected
37 << ", but got " << actual << "\n";
38 any_failed = true;
42 int
43 ACE_TMAIN (int, ACE_TCHAR *[])
45 bool any_failed = false;
47 expect_equals<CORBA::UInt8> (any_failed, "u8_max", u8_max, 255);
48 expect_equals<CORBA::Int8> (any_failed, "i8_min", i8_min, -128);
49 expect_equals<CORBA::Int8> (any_failed, "i8_max", i8_max, 127);
50 expect_equals<CORBA::UInt16> (any_failed, "u16_max", u16_max, 65535);
51 expect_equals<CORBA::Int16> (any_failed, "i16_min", i16_min, -32768);
52 expect_equals<CORBA::Int16> (any_failed, "i16_max", i16_max, 32767);
53 expect_equals<CORBA::UInt32> (any_failed, "u32_max", u32_max, 4294967295);
54 expect_equals<CORBA::Int32> (any_failed, "i32_min", i32_min, -2147483647 - 1);
55 expect_equals<CORBA::Int32> (any_failed, "i32_max", i32_max, 2147483647);
56 expect_equals<CORBA::UInt64> (any_failed, "u64_max", u64_max, 18446744073709551615ULL);
57 expect_equals<CORBA::Int64> (any_failed, "i64_min", i64_min, -9223372036854775807 - 1);
58 expect_equals<CORBA::Int64> (any_failed, "i64_max", i64_max, 9223372036854775807);
60 expect_equals<CORBA::UInt8> (any_failed, "u8_min_overflow", u8_min_overflow, u8_max);
61 expect_equals<CORBA::Int8> (any_failed, "i8_min_overflow", i8_min_overflow, i8_max);
62 expect_equals<CORBA::UInt8> (any_failed, "u8_max_overflow", u8_max_overflow, 0);
63 expect_equals<CORBA::Int8> (any_failed, "i8_max_overflow", i8_max_overflow, i8_min);
65 expect_equals<CORBA::UInt8> (any_failed, "u8_max_negate", u8_max_negate, 0);
66 expect_equals<CORBA::Int8> (any_failed, "i8_max_negate", i8_max_negate, i8_min);
68 expect_equals<CORBA::UInt8> (any_failed, "u8_e1", u8_e1, 2);
69 expect_equals<CORBA::UInt8> (any_failed, "u8_e2", u8_e2, 4);
70 expect_equals<CORBA::UInt8> (any_failed, "u8_e3", u8_e3, 12);
71 expect_equals<CORBA::UInt8> (any_failed, "u8_e4", u8_e4, 3);
72 expect_equals<CORBA::UInt8> (any_failed, "u8_e5", u8_e5, 7);
73 expect_equals<CORBA::UInt8> (any_failed, "u8_e6", u8_e6, 1);
74 expect_equals<CORBA::UInt8> (any_failed, "u8_e7", u8_e7, 1);
75 expect_equals<CORBA::UInt8> (any_failed, "u8_e8", u8_e8, 16);
76 expect_equals<CORBA::UInt8> (any_failed, "u8_e9", u8_e9, 8);
78 expect_equals<CORBA::Int8> (any_failed, "i8_e1", i8_e1, -2);
79 expect_equals<CORBA::Int8> (any_failed, "i8_e2", i8_e2, 4);
80 expect_equals<CORBA::Int8> (any_failed, "i8_e3", i8_e3, 12);
81 expect_equals<CORBA::Int8> (any_failed, "i8_e4", i8_e4, 3);
82 expect_equals<CORBA::Int8> (any_failed, "i8_e5", i8_e5, 7);
83 expect_equals<CORBA::Int8> (any_failed, "i8_e6", i8_e6, 1);
84 expect_equals<CORBA::Int8> (any_failed, "i8_e7", i8_e7, 1);
85 expect_equals<CORBA::Int8> (any_failed, "i8_e8", i8_e8, 16);
86 expect_equals<CORBA::Int8> (any_failed, "i8_e9", i8_e9, 8);
88 return any_failed ? EXIT_FAILURE : EXIT_SUCCESS;