/*---------------------------------------------------------------------------* * testhashmap.cpp * * * * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * * * * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * *---------------------------------------------------------------------------*/ #include #include #include #include "../src/hashmap.h" using namespace std; #if 1 void test1(); void test2(); void main(int argc, char* argv[]) { test2(); } // (INT,INT) hash void test1() { HashMap myHash; int value; int i; i=10; myHash.setName("TestHash"); myHash.insert(1, i); myHash.getValue(1, &value); std::cout << "Index 1 has value= " << value < myHash; string value = "hello"; int i; i=10; myHash.setName("TestHash"); myHash.insert(1, value); myHash.insert(2, "world"); myHash.getValue(1, &value); std::cout << "Index 1 has value= " << value < myHash; void main(int argc, char* argv[]) { string s; s = "hello"; insert(1,s); insert(2,"world"); finds(2); finds(1); finds(99); findi("hello"); findi("world"); findi("xox"); s = "bollocks"; findi("hello"); finds(1); insert(3,s); finds(3); insert(3,"zzz"); finds(3); remove(3); insert(3,"zzz"); finds(3); } void findi(string s) { int i; if ( myHash.getIndex(s, &i) ) { cout << "'" << s << "' has index of " << i <