MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stdcxx-t.cc
1 /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 // First include (the generated) my_config.h, to get correct platform defines.
17 #include "my_config.h"
18 #include <gtest/gtest.h>
19 
20 #if defined(__GNUC__) && __GNUC__ > 3
21 #include <tr1/unordered_map>
22 #elif defined(__WIN__)
23 #include <hash_map>
24 #elif defined(__SUNPRO_CC)
25 #include <hash_map>
26 #else
27 #error "Don't know how to implement hash_map"
28 #endif
29 
30 
31 template<typename K, typename T>
32 struct MyHashMap
33 {
34 #if defined(__GNUC__) && __GNUC__ > 3
35  typedef std::tr1::unordered_map<K, T> Type;
36 #elif defined(__WIN__)
37  typedef stdext::hash_map<K, T> Type;
38 #elif defined(__SUNPRO_CC)
39  typedef std::hash_map<K, T> Type;
40 #endif
41 };
42 
43 
44 TEST(STDfeatures, HashMap)
45 {
47  for (int ix= 0; ix < 10; ++ix)
48  {
49  intmap[ix]= ix * ix;
50  }
51  int t= intmap[0];
52  EXPECT_EQ(0, t);
53  EXPECT_TRUE(0 == intmap.count(42));
54  EXPECT_TRUE(intmap.end() == intmap.find(42));
55 }