diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-04 08:25:27 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-04 08:25:27 +0000 |
commit | 93b4311ec91b2d008ecc3a26200e4a44481494e8 (patch) | |
tree | c8f6ac63d26985c0b40ef84e7611871cfffb0b4b /ASNMP/tests/Gauge_Test.cpp | |
parent | 95433e3dbe5d6d6fc4ba640a14d290b609b90a73 (diff) | |
download | ATCD-93b4311ec91b2d008ecc3a26200e4a44481494e8.tar.gz |
*** empty log message ***
Diffstat (limited to 'ASNMP/tests/Gauge_Test.cpp')
-rw-r--r-- | ASNMP/tests/Gauge_Test.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/ASNMP/tests/Gauge_Test.cpp b/ASNMP/tests/Gauge_Test.cpp new file mode 100644 index 00000000000..ad1d4fa2912 --- /dev/null +++ b/ASNMP/tests/Gauge_Test.cpp @@ -0,0 +1,132 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// tests +// +// = FILENAME +// Guage_Test.cpp +// +// = DESCRIPTION +// Test all the member functions of the Guage class. An Object +// representing an ASN.1 Counter SMI GUAGE SYNTAX. +// = AUTHOR +// Michael R. MacFaden <mrm@cisco.com> +// +// ============================================================================ +/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Copyright 1997 Cisco Systems, Inc. + +Permission to use, copy, modify, and distribute this software for any +purpose and without fee is hereby granted, provided that this +copyright and permission notice appear on all copies of the software and +supporting documentation, the name of Cisco Systems, Inc. not be used +in advertising or publicity pertaining to distribution of the +program without specific prior permission, and notice be given +in supporting documentation that modification, copying and distribution is by +permission of Cisco Systems, Inc. + +Cisco Systems, Inc. makes no representations about the suitability of this +software for any purpose. THIS SOFTWARE IS PROVIDED ``AS IS'' +AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT +LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGMENT AND +FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL CISCO SYSTEMS, INC. BE +LIABLE FOR ANY DAMAGES ARISING OUT OF THIS LICENSE OR YOUR USE OF THE +SOFTWARE INCLUDING WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL +DAMAGES. +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +#include "ace/OS.h" +#include "asnmp/gauge.h" +#include "test_config.h" + +// hack: do this so when linking SUNC 4.x compiler will instantiate template +#include "ace/Containers.h" +ACE_Unbounded_Set<ACE_Log_Msg*> x; + +/* + Gauge32( void); + Gauge32( const unsigned long i); + Gauge32 ( const Gauge32 &g); + ~Gauge32(); + SmiUINT32 get_syntax(); + SnmpSyntax *clone() const; + Gauge32& operator=( const Gauge32 &uli); + Gauge32& operator=( const unsigned long i); + operator unsigned long(); + SnmpSyntax& operator=( SnmpSyntax &val); + +-- What is a Gauge? According to RFC 1155 section: 3.2.3.4 + This application-wide type represents a non-negative integer + which may increase or decreae, but which latches at a maximum + value of 2^32-1 (4294967295 dec) for gauges. + */ +static void TestGuage() +{ + long l = LONG_MAX, nl = LONG_MIN; // limits.h + unsigned long ul = ULONG_MAX, def = 0; + int i = INT_MAX, ni = INT_MIN; + unsigned int ui = UINT_MAX; + unsigned short us = 10; + short si = 65535; + + // constructors + Gauge32 g1; + ACE_ASSERT(g1 == def); + Gauge32 g2(l); + ACE_ASSERT(g2 == l); + Gauge32 g3(nl); + ACE_ASSERT(g3 == nl); + Gauge32 g4(ul); + ACE_ASSERT(g4 == ul); + Gauge32 g5(i); + ACE_ASSERT(g5 == i); + Gauge32 g6(ni); + ACE_ASSERT(g6 == ni); + Gauge32 g7(ui); + ACE_ASSERT(g7 == ui); + Gauge32 *g8 = new Gauge32(g5); + ACE_ASSERT(g8 != 0); + delete g8; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g1(\"\") [%u]\n", + (unsigned long)g1)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g2(\"%u\") [%u]\n", + l, (unsigned long)g2)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g3(\"%u\") [%u]\n", + nl, (unsigned long)g3)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g4(\"%u\") [%u]\n", + ul, (unsigned long)g4)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g5(\"%u\") [%u]\n", + i, (unsigned long)g5)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g6(\"%u\") [%u]\n", + ni, (unsigned long)g6)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) g7(\"%u\") [%u]\n", + ui, (unsigned long)g7)); + + // assignent + g1 = g2; // obj + ACE_ASSERT(g1 == g2); + g1 = g1; // self + ACE_ASSERT(g1 == g1); + g1 = def; // unsigned long + ACE_ASSERT(g1 == def); + g1 = us; // unsigned short + ACE_ASSERT(g1 == us); + g1 = si; // unsigned short + ACE_ASSERT(g1 == si); +} + +int +main (int, char *[]) +{ + ACE_START_TEST ("Guage_Test"); + + TestGuage(); + + ACE_END_TEST; + return 0; +} + |