Browse Source

[trac846] Fix confused test function

It seemed this function is supposed to remove given element from list,
but the counting was somehow confused.
Michal 'vorner' Vaner 14 years ago
parent
commit
74472396fc
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/lib/config/tests/fake_session.cc

+ 6 - 4
src/lib/config/tests/fake_session.cc

@@ -52,15 +52,17 @@ listContains(ConstElementPtr list, ConstElementPtr el) {
 
 
 void
 void
 listRemove(ElementPtr list, ConstElementPtr el) {
 listRemove(ElementPtr list, ConstElementPtr el) {
-    int i = -1;
+    int i = 0;
+    int position = -1;
     BOOST_FOREACH(ConstElementPtr s_el, list->listValue()) {
     BOOST_FOREACH(ConstElementPtr s_el, list->listValue()) {
         if (*el == *s_el) {
         if (*el == *s_el) {
-            i = 0;
+            position = i;
+            break;
         }
         }
         i++;
         i++;
     }
     }
-    if (i >= 0) {
-        list->remove(i);
+    if (position >= 0) {
+        list->remove(position);
     }
     }
 }
 }
 // endwant
 // endwant