source: icXML/icXML-devel/tests/src/UtilTests/CoreTests_RefHashTable.cpp @ 2733

Last change on this file since 2733 was 2733, checked in by cameron, 6 years ago

More path fixes.

File size: 3.7 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: CoreTests_RefHashTable.cpp 470088 2006-11-01 20:35:12Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  XML4C2 includes
24// ---------------------------------------------------------------------------
25#include "CoreTests.hpp"
26#include <icxercesc/util/RefHashTableOf.hpp>
27
28
29// ---------------------------------------------------------------------------
30//  A simple class to test the ref hash table with
31// ---------------------------------------------------------------------------
32class TestElem
33{
34    public :
35        TestElem(   const   XMLCh* const    key
36                    , const unsigned int    value1
37                    , const double          value2) :
38            fKey(XMLString::replicate(key))
39            , fValue1(value1)
40            , fValue2(value2)
41        {
42        }
43
44        ~TestElem()
45        {
46            XMLString::release(&fKey);
47        }
48
49        const XMLCh* getKey() const
50        {
51            return fKey;
52        }
53
54
55    private :
56        XMLCh*          fKey;
57        unsigned int    fValue1;
58        double          fValue2;
59};
60
61
62// ---------------------------------------------------------------------------
63//  Force a full instantiation of our hashtable, and its enumerator, just to
64//  insure that all methods get instantiated and compiled.
65// ---------------------------------------------------------------------------
66template RefHashTableOf<TestElem>;
67template RefHashTableOfEnumerator<TestElem>;
68
69
70
71// ---------------------------------------------------------------------------
72//  Local testing methods
73// ---------------------------------------------------------------------------
74static bool basicTests()
75{
76
77    return true;
78}
79
80
81// ---------------------------------------------------------------------------
82//  Test entry point
83// ---------------------------------------------------------------------------
84bool testRefHashTable()
85{
86    XERCES_STD_QUALIFIER wcout  << L"----------------------------------\n"
87                << L"Testing RefHashTableOf class\n"
88                << L"----------------------------------" << XERCES_STD_QUALIFIER endl;
89
90    bool retVal = true;
91
92    try
93    {
94        XERCES_STD_QUALIFIER wcout << L"Testing basic RefHashtable methods" << XERCES_STD_QUALIFIER endl;
95        if (!basicTests())
96        {
97            XERCES_STD_QUALIFIER wcout  << L"RefHashtable basic test methods failed"
98                        << XERCES_STD_QUALIFIER endl;
99            retVal = false;
100        }
101         else
102        {
103            XERCES_STD_QUALIFIER wcout << L"RefHashtable basic tests passed" << XERCES_STD_QUALIFIER endl;
104        }
105        XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
106    }
107
108    catch(const XMLException& toCatch)
109    {
110        XERCES_STD_QUALIFIER wcout  << L"  ERROR: Unexpected exception!\n   Msg: "
111                    << toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
112        return false;
113    }
114    return retVal;
115}
Note: See TracBrowser for help on using the repository browser.