Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ASNMP / tests / Gauge_Test.cpp
blob6081ac5e059c9e9d0eaab30fe7b74a3c4118afcb
2 //=============================================================================
3 /**
4 * @file Gauge_Test.cpp
6 * Test all the member functions of the Guage class. An Object
7 * representing an ASN.1 Counter SMI GUAGE SYNTAX.
9 * @author Michael R. MacFaden <mrm@cisco.com>
11 //=============================================================================
13 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
14 Copyright 1997 Cisco Systems, Inc.
16 Permission to use, copy, modify, and distribute this software for any
17 purpose and without fee is hereby granted, provided that this
18 copyright and permission notice appear on all copies of the software and
19 supporting documentation, the name of Cisco Systems, Inc. not be used
20 in advertising or publicity pertaining to distribution of the
21 program without specific prior permission, and notice be given
22 in supporting documentation that modification, copying and distribution is by
23 permission of Cisco Systems, Inc.
25 Cisco Systems, Inc. makes no representations about the suitability of this
26 software for any purpose. THIS SOFTWARE IS PROVIDED ``AS IS''
27 AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
28 LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGMENT AND
29 FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL CISCO SYSTEMS, INC. BE
30 LIABLE FOR ANY DAMAGES ARISING OUT OF THIS LICENSE OR YOUR USE OF THE
31 SOFTWARE INCLUDING WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL
32 DAMAGES.
33 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
35 #include "ace/OS_main.h"
36 #include "asnmp/gauge.h"
37 #include "test_config.h"
40 Gauge32();
41 Gauge32( const unsigned long i);
42 Gauge32 ( const Gauge32 &g);
43 ~Gauge32();
44 SmiUINT32 get_syntax();
45 SnmpSyntax *clone() const;
46 Gauge32& operator=( const Gauge32 &uli);
47 Gauge32& operator=( const unsigned long i);
48 operator unsigned long();
49 SnmpSyntax& operator=( SnmpSyntax &val);
51 -- What is a Gauge? According to RFC 1155 section: 3.2.3.4
52 This application-wide type represents a non-negative integer
53 which may increase or decrease, but which latches at a maximum
54 value of 2^32-1 (4294967295 dec) for gauges.
56 static void
57 TestGuage ()
59 #if !defined (ACE_WIN32)
60 long l = LONG_MAX, nl = LONG_MIN; // limits.h
61 unsigned long ul = ULONG_MAX, def = 0;
62 int i = INT_MAX, ni = INT_MIN;
63 unsigned int ui = UINT_MAX;
64 unsigned short us = 10;
65 short si = static_cast<short> (65535);
67 // constructors
68 Gauge32 g1;
69 ACE_ASSERT(g1 == def);
70 Gauge32 g2(l);
71 ACE_ASSERT(g2 == static_cast<unsigned long> (l));
72 Gauge32 g3(nl);
73 ACE_ASSERT(g3 == static_cast<unsigned long> (nl));
74 Gauge32 g4(ul);
75 ACE_ASSERT(g4 == ul);
76 Gauge32 g5(i);
77 ACE_ASSERT(g5 == static_cast<unsigned long> (i));
78 Gauge32 g6(ni);
79 ACE_ASSERT(g6 == static_cast<unsigned long> (ni));
80 Gauge32 g7(ui);
81 ACE_ASSERT(g7 == ui);
82 Gauge32 *g8 = new Gauge32(g5);
83 ACE_ASSERT(g8 != 0);
84 delete g8;
86 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g1(\"\") [%u]\n",
87 (unsigned long)g1));
88 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g2(\"%u\") [%u]\n",
89 l, (unsigned long)g2));
90 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g3(\"%u\") [%u]\n",
91 nl, (unsigned long)g3));
92 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g4(\"%u\") [%u]\n",
93 ul, (unsigned long)g4));
94 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g5(\"%u\") [%u]\n",
95 i, (unsigned long)g5));
96 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g6(\"%u\") [%u]\n",
97 ni, (unsigned long)g6));
98 ACE_DEBUG ((LM_DEBUG, "(%P|%t) g7(\"%u\") [%u]\n",
99 ui, (unsigned long)g7));
101 // assignent
102 g1 = g2; // obj
103 ACE_ASSERT(g1 == g2);
104 g1 = g1; // self
105 ACE_ASSERT(g1 == g1);
106 g1 = def; // unsigned long
107 ACE_ASSERT(g1 == def);
108 g1 = us; // unsigned short
109 ACE_ASSERT(g1 == static_cast<unsigned long> (us));
110 g1 = si; // unsigned short
111 ACE_ASSERT(g1 == static_cast<unsigned long> (si));
112 #endif /*ACE_WIN32*/
116 ACE_TMAIN (int, ACE_TCHAR *[])
118 ACE_START_TEST (ACE_TEXT ("Gauge_Test"));
120 TestGuage();
122 ACE_END_TEST;
123 return 0;