2 //=============================================================================
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
33 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
35 #include "ace/OS_main.h"
36 #include "asnmp/gauge.h"
37 #include "test_config.h"
41 Gauge32( const unsigned long i);
42 Gauge32 ( const Gauge32 &g);
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.
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);
69 ACE_ASSERT(g1
== def
);
71 ACE_ASSERT(g2
== static_cast<unsigned long> (l
));
73 ACE_ASSERT(g3
== static_cast<unsigned long> (nl
));
77 ACE_ASSERT(g5
== static_cast<unsigned long> (i
));
79 ACE_ASSERT(g6
== static_cast<unsigned long> (ni
));
82 Gauge32
*g8
= new Gauge32(g5
);
86 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) g1(\"\") [%u]\n",
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
));
103 ACE_ASSERT(g1
== g2
);
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
));
116 ACE_TMAIN (int, ACE_TCHAR
*[])
118 ACE_START_TEST (ACE_TEXT ("Gauge_Test"));