/[resiprocate]/main/rutil/test/testCompat.cxx
ViewVC logotype

Contents of /main/rutil/test/testCompat.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10599 - (show annotations) (download)
Sun Sep 29 10:46:54 2013 UTC (6 years, 1 month ago) by dpocock
File size: 2211 byte(s)
rutil: add ntoh64 and hton64
1 #include <cassert>
2
3 #include "rutil/compat.hxx"
4
5 using namespace resip;
6 using namespace std;
7
8 int
9 main()
10 {
11
12 // make sure these are consistent on all platforms
13
14 assert(sizeof(UInt8) == 1);
15 assert(sizeof(UInt16) == 2);
16 assert(sizeof(UInt32) == 4);
17 assert(sizeof(Int32) == 4);
18 assert(sizeof(UInt64) == 8);
19
20 UInt64 data = 0;
21 UInt8 *tmp = (UInt8*)&data;
22 tmp[7] = 1;
23 assert(ntoh64(data) == 1);
24 UInt64 data2 = hton64(data);
25 assert(tmp[7] == 1);
26
27 return 0;
28 }
29
30 /* ====================================================================
31 *
32 * Copyright (c) 2013 Daniel Pocock All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 *
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 *
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in
43 * the documentation and/or other materials provided with the
44 * distribution.
45 *
46 * 3. Neither the name of the author(s) nor the names of any contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * ====================================================================
63 *
64 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27