=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tests / CDR / alignment.cpp
blob2cd4496da2bbd3dd7eb27e921cc022e546fed890
2 //=============================================================================
3 /**
4 * @file alignment.cpp
6 * Verifies that octet sequence marshaling does not affect
7 * marshaling.
9 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
11 //=============================================================================
14 #include "tao/CDR.h"
16 #include "ace/Log_Msg.h"
18 int ACE_TMAIN (int, ACE_TCHAR *[])
20 int status = 0;
22 for (CORBA::ULong i = 16; i != 64; ++i)
24 ACE_Message_Block mb (i + ACE_CDR::MAX_ALIGNMENT);
25 ACE_CDR::mb_align (&mb);
26 mb.wr_ptr (i);
28 CORBA::Double dbl = i;
30 TAO_OutputCDR cdr;
31 cdr.write_ulong (i); // length
32 cdr.write_octet_array_mb (&mb);
33 cdr.write_double (dbl);
34 cdr.write_double (dbl);
36 TAO_InputCDR input (cdr);
38 CORBA::ULong len;
40 input.read_ulong (len);
42 if (len != i)
44 ACE_DEBUG ((LM_DEBUG,
45 "ERROR: mismatched lengths,"
46 " got %d, expected %d\n",
47 len, i));
50 ACE_Message_Block read_mb (len + ACE_CDR::MAX_ALIGNMENT);
51 ACE_CDR::mb_align (&mb);
52 mb.wr_ptr (len);
53 input.read_char_array (mb.rd_ptr (), len);
55 CORBA::Double read_dbl;
56 if (input.read_double (read_dbl) == 0)
57 ACE_DEBUG ((LM_DEBUG, "Failure reading double...\n"));
59 if (!ACE::is_equal (read_dbl, dbl))
61 status = 1;
62 ACE_DEBUG ((LM_DEBUG,
63 "ERROR: mismatched doubles,"
64 " got %f, expected %f\n",
65 read_dbl, dbl));
66 for (const ACE_Message_Block *j = cdr.begin ();
67 j != cdr.end ();
68 j = j->cont ())
70 ACE_HEX_DUMP ((LM_DEBUG,
71 j->rd_ptr (),
72 j->length (),
73 ACE_TEXT("Output CDR stream")));
75 TAO_InputCDR debug (cdr);
76 ACE_HEX_DUMP ((LM_DEBUG,
77 debug.rd_ptr (),
78 debug.length (),
79 ACE_TEXT("Input CDR stream")));
83 return status;