2 //=============================================================================
4 * @file Varbind_Test.cpp
6 * Test all the member functions of the Varbind class.
7 * A varbind is a list of { oids and associated values }
9 * @author Michael R. MacFaden <mrm@cisco.com>
11 //=============================================================================
14 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
15 Copyright 1997 Cisco Systems, Inc.
17 Permission to use, copy, modify, and distribute this software for any
18 purpose and without fee is hereby granted, provided that this
19 copyright and permission notice appear on all copies of the software and
20 supporting documentation, the name of Cisco Systems, Inc. not be used
21 in advertising or publicity pertaining to distribution of the
22 program without specific prior permission, and notice be given
23 in supporting documentation that modification, copying and distribution is by
24 permission of Cisco Systems, Inc.
26 Cisco Systems, Inc. makes no representations about the suitability of this
27 software for any purpose. THIS SOFTWARE IS PROVIDED ``AS IS''
28 AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
29 LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGMENT AND
30 FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL CISCO SYSTEMS, INC. BE
31 LIABLE FOR ANY DAMAGES ARISING OUT OF THIS LICENSE OR YOUR USE OF THE
32 SOFTWARE INCLUDING WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL
34 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
36 #include "ace/OS_main.h"
37 #include "asnmp/oid.h"
39 #include "test_config.h"
45 Vb( const Oid& vb, const SnmpSyntax &val, const SmiUINT32=SNMP_CLASS_SUCCESS);
48 Vb& operator=( const Vb &vb);
49 void set_oid( const Oid& oid);
50 void get_oid( Oid &oid) const;
52 void set_value( const TimeTicks& ticks);
53 void set_value( const Oid& oid);
54 void set_value( const Counter32& ctr);
55 void set_value( const Counter64& ctr);
56 void set_value( const Gauge32& ctr);
57 void set_value( const SnmpUInt32& ctr);
58 void set_value( const SnmpInt32& ctr);
59 void set_value( const OctetStr& oct_str);
60 int get_value( TimeTicks& ticks);
61 int get_value( Oid& oid);
62 int get_value( Counter32& ctr);
63 int get_value( Counter64& ctr);
64 int get_value( Gauge32& ctr);
65 int get_value( SnmpUInt32& ctr);
66 int get_value( SnmpInt32& ctr);
67 int get_value( OctetStr& oct_str);
68 int get_value( SnmpSyntax &val);
69 void set_value( const SnmpSyntax &val);
70 int get_value( const SnmpSyntax &val);
71 SmiUINT32 get_syntax();
72 friend void set_exception_status( Vb *vb, const SmiUINT32 status);
74 char *to_string_value();
75 char *to_string_oid();
80 #if !defined (ACE_WIN32)
83 ACE_ASSERT(v1
.valid() == 0);
84 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) VarBinad:v1(\"/\") [%s]\n",
87 // purpose of this routine??
88 set_exception_status( &v1
, 10);
91 ACE_ASSERT(v2
.valid() == 0);
94 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) VarBinad:v2(\"1.2.3/\") [%s]\n",
99 ACE_ASSERT(v2
.valid() == 0);
101 ACE_ASSERT(v2
.valid() == 0);
108 ACE_ASSERT(v3
.valid() == 1);
115 ACE_ASSERT(v4
.valid() == 1);
117 ACE_ASSERT(o1
== o2
);
120 Counter32
c1(12), c2
;
123 ACE_ASSERT(v5
.valid() == 1);
125 ACE_ASSERT(c1
== c2
);
128 Counter64
c3(12345678901234ULL), c4
;
131 ACE_ASSERT(v6
.valid() == 1);
133 ACE_ASSERT(c3
== c4
);
136 Gauge32
g1(0123456), g2
;
139 ACE_ASSERT(v7
.valid() == 1);
141 ACE_ASSERT(g1
== g2
);
144 SnmpInt32
i1(0123456), i2
;
147 ACE_ASSERT(v8
.valid() == 1);
149 ACE_ASSERT(i1
== i2
);
152 SnmpUInt32
u1(0123456), u2
;
155 ACE_ASSERT(v9
.valid() == 1);
157 ACE_ASSERT(u1
== u2
);
160 OctetStr
s1(" abcdefghighlmnopqrstuvwxyz!@#$%^&*()"), s2
;
163 ACE_ASSERT(v10
.valid() == 1);
165 ACE_ASSERT(s1
== s2
);
166 ACE_ASSERT(s1
.length() == s2
.length());
168 // test assignment over all datatypes
170 ACE_ASSERT(v10
== v5
);
173 Vb
v11(o1
, s1
, SNMP_CLASS_SUCCESS
);
174 ACE_ASSERT(v11
.valid() == 1);
176 ACE_ASSERT(o1
== o2
);
178 ACE_ASSERT(s1
== s2
);
179 #endif /*if ACE_WIN32*/
183 ACE_TMAIN (int, ACE_TCHAR
*[])
185 ACE_START_TEST (ACE_TEXT ("Varbind_Test"));