Parcourir la 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 il y a 14 ans
Parent
commit
74472396fc
1 fichiers modifiés avec 6 ajouts et 4 suppressions
  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
 listRemove(ElementPtr list, ConstElementPtr el) {
-    int i = -1;
+    int i = 0;
+    int position = -1;
     BOOST_FOREACH(ConstElementPtr s_el, list->listValue()) {
         if (*el == *s_el) {
-            i = 0;
+            position = i;
+            break;
         }
         i++;
     }
-    if (i >= 0) {
-        list->remove(i);
+    if (position >= 0) {
+        list->remove(position);
     }
 }
 // endwant