@@ -146,17 +146,13 @@ TEST (JavaUtil, HashMapContainsValue) {
146146
147147TEST (JavaUtil, HashMapEntrySet) {
148148 HashMap<String, String> hashMap;
149-
150149 int index = 1 ;
151-
152150 for (index; index <= 100 ; index++) {
153151 hashMap.put (" Key " + String::valueOf (index),
154152 " Value " + String::valueOf (index));
155153 }
156-
157154 int counter = 0 ;
158155 Set<class Map <String, String>::Entry> entrySet = hashMap.entrySet ();
159-
160156 // TODO - loint@foodtiny.com will improve entrySet
161157 // then we can put it inside foreach without any performance issue
162158 for (Map<String, String>::Entry entry : entrySet) {
@@ -170,9 +166,18 @@ TEST (JavaUtil, HashMapEntrySet) {
170166 assertEquals (" Value 98" , entry.getValue ().toString ());
171167 }
172168 }
173-
174169 // Make sure foreach is working
175170 assertEquals (100 , counter);
171+
172+ HashMap<String, String*> hashMapStringPointer;
173+ hashMapStringPointer.put (" test1" , new String (" test1" ));
174+ hashMapStringPointer.put (" test2" , new String (" test1" ));
175+ hashMapStringPointer.put (" test3" , new String (" test1" ));
176+ for (Map<String, String*>::Entry entry : hashMapStringPointer.entrySet ()) {
177+ assertEquals (" test1" , entry.getValue ()->toString ());
178+ String *stringValue = entry.getValue ();
179+ delete stringValue;
180+ }
176181}
177182
178183TEST (JavaUtil, HashMapGet) {
@@ -849,7 +854,7 @@ TEST (JavaUtil, HashMapReinitialize) {
849854// assertEquals(2, hashMap.size());
850855// assertEquals(0, resultComputeIfPresentDefaultValueHashMap.intValue());
851856// }
852- //
857+
853858// TEST(JavaUtil, HashMapForEach) {
854859// /* Test HashMap<String, Integer> */
855860// // Create a HashMap
@@ -859,10 +864,9 @@ TEST (JavaUtil, HashMapReinitialize) {
859864// Integer result;
860865//
861866// // Create function
862- // std::function<void(String, Integer)> function
863- // = [] (String key, Integer value) {
864- // printf("TEST(JavaUtil, HashMapForEach) is OK");
865- // };
867+ // std::function<void(String, Integer)> function = [] (String key, Integer value) {
868+ // printf("TEST(JavaUtil, HashMapForEach) is OK");
869+ // };
866870//
867871// // foreach
868872// hashMap.forEach(function);
0 commit comments