OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-cog commits / 1fbd30c

Unit-test fixes: many off-by-one dure to new flag.
Adding the flag is the right thing to do. But the unit tests suffer on account of it.
1fbd30ca1e11986fd6d677be6066e3c423eda79a
by Linas Vepstas <linasvepstas@gmail.com> · 2025-12-09T01:01:26.000Z

Changed files (9) +133 -134

tests/persist/cog-simple/SimpleBasicDeleteUTest.cxxtest +38 -45
……@@ -139,9 +139,7 @@ void SimpleBasicDeleteUTest::test_duplicates(void)
139139 TS_ASSERT_EQUALS(as->get_size(), 3);
140140 store->open();
141141 store->load_atomspace();
142 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
143 if (tvk) as->extract_atom(tvk);
144 TS_ASSERT_EQUALS(as->get_size(), 3);
142 TS_ASSERT_EQUALS(as->get_size(), 5);
145143
146144 store->erase();
147145 store->close();
……@@ -198,9 +196,8 @@ void SimpleBasicDeleteUTest::test_recursive(void)
198196 as->extract_atom(ha, true);
199197 store->open();
200198 store->load_atomspace();
201 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
202 if (tvk) as->extract_atom(tvk);
203 TS_ASSERT_EQUALS(as->get_size(), 2);
199 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
200 TS_ASSERT_EQUALS(as->get_size(), 4);
204201
205202 // --------------------------------------
206203 // Do it again, but with a different order.
……@@ -213,18 +210,16 @@ void SimpleBasicDeleteUTest::test_recursive(void)
213210 store->close();
214211 store->open();
215212 store->load_atomspace();
216 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
217 if (tvk) as->extract_atom(tvk);
218 TS_ASSERT_EQUALS(as->get_size(), 5);
213 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
214 TS_ASSERT_EQUALS(as->get_size(), 7);
219215
220216 store->remove_atom(as, ha, true);
221217 store->close();
222218 as->extract_atom(ha, true);
223219 store->open();
224220 store->load_atomspace();
225 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
226 if (tvk) as->extract_atom(tvk);
227 TS_ASSERT_EQUALS(as->get_size(), 2);
221 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
222 TS_ASSERT_EQUALS(as->get_size(), 4);
228223
229224 // --------------------------------------
230225 // Do it again, but with a complex order.
……@@ -237,18 +232,16 @@ void SimpleBasicDeleteUTest::test_recursive(void)
237232 store->close();
238233 store->open();
239234 store->load_atomspace();
240 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
241 if (tvk) as->extract_atom(tvk);
242 TS_ASSERT_EQUALS(as->get_size(), 5);
235 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
236 TS_ASSERT_EQUALS(as->get_size(), 7);
243237
244238 store->remove_atom(as, ha, true);
245239 store->close();
246240 as->extract_atom(ha, true);
247241 store->open();
248242 store->load_atomspace();
249 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
250 if (tvk) as->extract_atom(tvk);
251 TS_ASSERT_EQUALS(as->get_size(), 2);
243 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
244 TS_ASSERT_EQUALS(as->get_size(), 4);
252245
253246 // --------------------------------------
254247 // Do it again, but more deeply.
……@@ -262,18 +255,16 @@ void SimpleBasicDeleteUTest::test_recursive(void)
262255 store->close();
263256 store->open();
264257 store->load_atomspace();
265 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
266 if (tvk) as->extract_atom(tvk);
267 TS_ASSERT_EQUALS(as->get_size(), 6);
258 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
259 TS_ASSERT_EQUALS(as->get_size(), 8);
268260
269261 store->remove_atom(as, ha, true);
270262 store->close();
271263 as->extract_atom(ha, true);
272264 store->open();
273265 store->load_atomspace();
274 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
275 if (tvk) as->extract_atom(tvk);
276 TS_ASSERT_EQUALS(as->get_size(), 2);
266 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
267 TS_ASSERT_EQUALS(as->get_size(), 4);
277268
278269 // --------------------------------------
279270 store->erase();
……@@ -313,8 +304,8 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
313304 store->store_atom(ha);
314305 store->barrier();
315306
316 // Verify the atomspace size
317 TS_ASSERT_EQUALS(as->get_size(), 5);
307 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
308 TS_ASSERT_EQUALS(as->get_size(), 6);
318309
319310 // Verify that there are three keys
320311 HandleSet hs = ha->getKeys();
……@@ -325,7 +316,8 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
325316 // Remove one of the keys
326317 store->remove_atom(as, kb);
327318 as->extract_atom(kb);
328 TS_ASSERT_EQUALS(as->get_size(), 4);
319 // +1 for *-IsKeyFlag-*
320 TS_ASSERT_EQUALS(as->get_size(), 5);
329321
330322 // Verify the key was deleted by loading only PredicateNodes.
331323 as = createAtomSpace();
……@@ -356,10 +348,10 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
356348 store->open();
357349 TS_ASSERT(store->connected())
358350
359 // We expect 5 keys, including the truth-value key.
351 // We expect 6 atoms (+1 for *-IsKeyFlag-*)
360352 printf("Loading the atomspace ...\n");
361353 store->load_atomspace();
362 TS_ASSERT_EQUALS(as->get_size(), 5);
354 TS_ASSERT_EQUALS(as->get_size(), 6);
363355
364356 // Verify that there are only two keys .. haha no, three.
365357 // That is because the deleted key gets restored when the
……@@ -414,13 +406,14 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
414406 store->store_atom(hb);
415407 store->barrier();
416408
417 // Verify the atomspace size
418 TS_ASSERT_EQUALS(as->get_size(), 4);
409 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
410 TS_ASSERT_EQUALS(as->get_size(), 5);
419411
420412 // Remove the value
421413 store->remove_atom(as, hx);
422414 as->extract_atom(hx);
423 TS_ASSERT_EQUALS(as->get_size(), 3);
415 // +1 for *-IsKeyFlag-*
416 TS_ASSERT_EQUALS(as->get_size(), 4);
424417
425418 // FYI, we should call store->close() at this point, but we
426419 // don't, because ... most users forget to do this too.
……@@ -439,7 +432,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
439432 store->open();
440433 TS_ASSERT(store->connected())
441434
442 // We expect 4 keys (the truth-value key doesn't show up.)
435 // We expect 5 atoms: b, x, key-x, *-IsKeyFlag-*, StorageNode
443436 // That's because the (Concept "x") sitting in the Value
444437 // was never actually deleted; thus it is restored.
445438 printf("Loading the atomspace ...\n");
……@@ -450,10 +443,9 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
450443 for (const Handle& h: hset)
451444 printf("Atomspace contains h=%s\n", h->to_short_string().c_str());
452445
453 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
454 if (tvk) as->extract_atom(tvk);
455 // Size stays at 4 because (Concept "x") cannot be deleted.
456 TS_ASSERT_EQUALS(as->get_size(), 4);
446 // Size is 5 because (Concept "x") cannot be deleted.
447 // +1 for *-IsKeyFlag-*
448 TS_ASSERT_EQUALS(as->get_size(), 5);
457449
458450 hb = as->add_node(CONCEPT_NODE, "b");
459451 hx = as->add_node(CONCEPT_NODE, "x");
……@@ -466,19 +458,20 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
466458 store->store_atom(hb);
467459 store->barrier();
468460
469 TS_ASSERT_EQUALS(as->get_size(), 6);
461 // +1 for *-IsKeyFlag-*
462 TS_ASSERT_EQUALS(as->get_size(), 7);
470463
471464 // Remove the value .. again
472465 store->remove_atom(as, hx);
473466 as->extract_atom(hx);
474 TS_ASSERT_EQUALS(as->get_size(), 5);
467 // +1 for *-IsKeyFlag-*
468 TS_ASSERT_EQUALS(as->get_size(), 6);
475469 store->close();
476470 store->open();
477471 store->load_atomspace();
478 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
479 if (tvk) as->extract_atom(tvk);
480 // Size stays at 6 because (Concept "x") cannot be deleted.
481 TS_ASSERT_EQUALS(as->get_size(), 6);
472 // Size is 7 because (Concept "x") cannot be deleted.
473 // +1 for *-IsKeyFlag-*
474 TS_ASSERT_EQUALS(as->get_size(), 7);
482475
483476 // We are done.
484477 store->close();
……@@ -495,10 +488,10 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
495488 store->open();
496489 TS_ASSERT(store->connected())
497490
498 // We expect 6 keys, (the truth-value key does not show.)
491 // We expect 7 atoms (+1 for *-IsKeyFlag-*)
499492 printf("Loading the atomspace ...\n");
500493 store->load_atomspace();
501 TS_ASSERT_EQUALS(as->get_size(), 6);
494 TS_ASSERT_EQUALS(as->get_size(), 7);
502495
503496 // Verify that there are two keys
504497 hb = as->add_node(CONCEPT_NODE, "b");
tests/persist/cog-simple/SimpleBasicSaveUTest.cxxtest +2 -2
……@@ -417,8 +417,8 @@ void BasicSaveUTest::test_table()
417417 size_t num_fetched = table2->get_size();
418418 printf("test_table: Done loading table; fetched %lu, expected %lu\n",
419419 num_fetched, num_stored);
420 // One extra, for the (PredicateNode "*-TruthValueKey-*")
421 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+1);
420 // Two extra: (PredicateNode "*-TruthValueKey-*") and (PredicateNode "*-IsKeyFlag-*")
421 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+2);
422422
423423 idx = 0;
424424 check_table(idx++, as2, "aaa ");
tests/persist/cog-simple/SimpleDeleteUTest.cxxtest +11 -8
……@@ -449,6 +449,7 @@ void DeleteUTest::test_remove(void)
449449 /* Push all atoms out to storage */
450450 store->store_atomspace();
451451
452 // +1 for (Predicate "*-IsKeyFlag-*")
452453 printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+1);
453454 TSM_ASSERT("Initial unexpected atomspace size",
454455 ((unsigned)(7*idx+1)) == _as->get_size());
……@@ -461,6 +462,7 @@ void DeleteUTest::test_remove(void)
461462 for (i=0; i<idx; i++)
462463 extract_links(i, _as);
463464
465 // +1 for (Predicate "*-IsKeyFlag-*")
464466 printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+1);
465467 TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+1)) == _as->get_size());
466468
……@@ -474,8 +476,8 @@ void DeleteUTest::test_remove(void)
474476 for (i=0; i<idx; i++)
475477 delete_links(i, store);
476478
477 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+2);
478 TSM_ASSERT("Post-remove unexpected atomspace size", ((unsigned)(4*idx+2)) == _as->get_size());
479 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3);
480 TSM_ASSERT("Post-remove unexpected atomspace size", ((unsigned)(4*idx+3)) == _as->get_size());
479481
480482 /* Verify that the atoms are really gone from storage. */
481483 for (i=0; i<idx; i++) {
……@@ -483,8 +485,8 @@ void DeleteUTest::test_remove(void)
483485 check_remove(i, _as, "verify-gone");
484486 }
485487
486 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+2);
487 TSM_ASSERT("Post-refetch unexpected atomspace size", ((unsigned)(7*idx+2)) == _as->get_size());
488 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3);
489 TSM_ASSERT("Post-refetch unexpected atomspace size", ((unsigned)(7*idx+3)) == _as->get_size());
488490
489491 /* Kill data for good */
490492 _as->clear();
……@@ -538,6 +540,7 @@ void DeleteUTest::test_recurse(void)
538540 for (i=0; i<zap; i++)
539541 extract_nodes(i, _as);
540542
543 // +1 for the *-IsKeyFlag-* predicate
541544 size_t expsz = 7*(idx-zap) + 3*zap + 1;
542545 printf("Atomspace size=%lu expect=%lu\n",
543546 _as->get_size(), expsz);
……@@ -554,8 +557,8 @@ void DeleteUTest::test_recurse(void)
554557 delete_nodes(i, store);
555558
556559 printf("Post-remove size=%lu expect=%lu\n",
557 _as->get_size(), expsz+1);
558 TSM_ASSERT("Unexpected atomspace size", expsz+1 == _as->get_size());
560 _as->get_size(), expsz+2);
561 TSM_ASSERT("Unexpected atomspace size", expsz+2 == _as->get_size());
559562
560563 store->barrier();
561564
……@@ -565,9 +568,9 @@ void DeleteUTest::test_recurse(void)
565568 }
566569
567570 printf("Post-refetch size=%lu expect=%d\n",
568 _as->get_size(), 7*idx+2);
571 _as->get_size(), 7*idx+3);
569572 TSM_ASSERT("Unexpected atomspace size",
570 ((unsigned) 7*idx+2) == _as->get_size());
573 ((unsigned) 7*idx+3) == _as->get_size());
571574
572575 /* Check that the removed atoms really got zapped. */
573576 for (i=0; i<zap; i++) {
tests/persist/cog-simple/SimpleMultiDeleteUTest.cxxtest +3 -3
……@@ -209,9 +209,9 @@ void SimpleMultiDeleteUTest::test_add_delete(void)
209209 store->load_atomspace();
210210 printf("Final AtomSpace size=%lu\n", as->get_size());
211211
212 // Size should be 19: the 18 from before plus that annoying
213 // (Predicate "*-TruthValueKey-*")
214 size_t expected_size = 3 + 6 + n_threads;
212 // Size should be 20: the 18 from before plus
213 // (Predicate "*-TruthValueKey-*") and (Predicate "*-IsKeyFlag-*")
214 size_t expected_size = 4 + 6 + n_threads;
215215 if (as->get_size() != expected_size)
216216 printf("Error: Bad size! AtomSpace contents =\n%s\n",
217217 as->to_string().c_str());
tests/persist/cog-simple/SimpleValueSaveUTest.cxxtest +13 -10
……@@ -353,10 +353,10 @@ void SimpleValueSaveUTest::test_load_by_type()
353353 store->fetch_all_atoms_of_type(CONCEPT_NODE);
354354 store->barrier();
355355
356 // Six: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*"
357 // and PredicateNode "some pred key" -- the two preds show up
358 // when the attached values are fetched.
359 TSM_ASSERT_EQUALS("Wrong number of Atoms fetched!", as->get_size(), 7);
356 // Seven: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*",
357 // PredicateNode "some pred key", and PredicateNode "*-IsKeyFlag-*"
358 // -- the preds show up when the attached values are fetched.
359 TSM_ASSERT_EQUALS("Wrong number of Atoms fetched!", as->get_size(), 8);
360360
361361 printf("Got %lu Atoms\n", as->get_size());
362362 HandleSeq hset;
……@@ -520,9 +520,10 @@ void SimpleValueSaveUTest::test_link_by_type()
520520 // The B-nodes are added after the fetch. In either case,
521521 // there should not be any values fetched for either A or B;
522522 // only the values on the C-links should be fetched.
523 // +1 for (PredicateNode "*-IsKeyFlag-*")
523524 store->fetch_all_atoms_of_type(LIST_LINK);
524525 store->barrier();
525 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
526 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
526527
527528 printf("Got %lu Atoms\n", as->get_size());
528529 HandleSeq hset;
……@@ -743,9 +744,10 @@ void SimpleValueSaveUTest::test_link_by_type_quoted()
743744 store->fetch_all_atoms_of_type(LIST_LINK);
744745 store->barrier();
745746
746 // We created 9 new atoms above, so expect 15 from before plus 9
747 printf ("fetched %lu atoms, expecting 24\n", as->get_size());
748 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 24);
747 // We created 9 new atoms above, so expect 16 from before plus 9
748 // (+1 for *-IsKeyFlag-*)
749 printf ("fetched %lu atoms, expecting 25\n", as->get_size());
750 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25);
749751
750752 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
751753 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -961,8 +963,9 @@ void SimpleValueSaveUTest::test_incoming()
961963 store->fetch_incoming_set(gat, false);
962964 store->fetch_incoming_set(gal, false);
963965 store->fetch_incoming_set(gav, false);
964 printf ("AtomSpace now contains %lu atoms, expecting 15\n", as->get_size());
965 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
966 // +1 for *-IsKeyFlag-*
967 printf ("AtomSpace now contains %lu atoms, expecting 16\n", as->get_size());
968 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
966969
967970 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
968971 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
tests/persist/cog-storage/BasicDeleteUTest.cxxtest +39 -45
……@@ -139,9 +139,8 @@ void BasicDeleteUTest::test_duplicates(void)
139139 TS_ASSERT_EQUALS(as->get_size(), 3);
140140 store->open();
141141 store->load_atomspace();
142 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
143 if (tvk) as->extract_atom(tvk);
144 TS_ASSERT_EQUALS(as->get_size(), 3);
142 // +1 for *-IsKeyFlag-*
143 TS_ASSERT_EQUALS(as->get_size(), 5);
145144
146145 store->erase();
147146 store->close();
……@@ -198,9 +197,8 @@ void BasicDeleteUTest::test_recursive(void)
198197 as->extract_atom(ha, true);
199198 store->open();
200199 store->load_atomspace();
201 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
202 if (tvk) as->extract_atom(tvk);
203 TS_ASSERT_EQUALS(as->get_size(), 2);
200 // +1 for *-IsKeyFlag-*
201 TS_ASSERT_EQUALS(as->get_size(), 4);
204202
205203 // --------------------------------------
206204 // Do it again, but with a different order.
……@@ -213,18 +211,16 @@ void BasicDeleteUTest::test_recursive(void)
213211 store->close();
214212 store->open();
215213 store->load_atomspace();
216 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
217 if (tvk) as->extract_atom(tvk);
218 TS_ASSERT_EQUALS(as->get_size(), 5);
214 // +1 for *-IsKeyFlag-*
215 TS_ASSERT_EQUALS(as->get_size(), 7);
219216
220217 store->remove_atom(as, ha, true);
221218 store->close();
222219 as->extract_atom(ha, true);
223220 store->open();
224221 store->load_atomspace();
225 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
226 if (tvk) as->extract_atom(tvk);
227 TS_ASSERT_EQUALS(as->get_size(), 2);
222 // +1 for *-IsKeyFlag-*
223 TS_ASSERT_EQUALS(as->get_size(), 4);
228224
229225 // --------------------------------------
230226 // Do it again, but with a complex order.
……@@ -237,18 +233,16 @@ void BasicDeleteUTest::test_recursive(void)
237233 store->close();
238234 store->open();
239235 store->load_atomspace();
240 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
241 if (tvk) as->extract_atom(tvk);
242 TS_ASSERT_EQUALS(as->get_size(), 5);
236 // +1 for *-IsKeyFlag-*
237 TS_ASSERT_EQUALS(as->get_size(), 7);
243238
244239 store->remove_atom(as, ha, true);
245240 store->close();
246241 as->extract_atom(ha, true);
247242 store->open();
248243 store->load_atomspace();
249 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
250 if (tvk) as->extract_atom(tvk);
251 TS_ASSERT_EQUALS(as->get_size(), 2);
244 // +1 for *-IsKeyFlag-*
245 TS_ASSERT_EQUALS(as->get_size(), 4);
252246
253247 // --------------------------------------
254248 // Do it again, but more deeply.
……@@ -262,18 +256,16 @@ void BasicDeleteUTest::test_recursive(void)
262256 store->close();
263257 store->open();
264258 store->load_atomspace();
265 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
266 if (tvk) as->extract_atom(tvk);
267 TS_ASSERT_EQUALS(as->get_size(), 6);
259 // +1 for *-IsKeyFlag-*
260 TS_ASSERT_EQUALS(as->get_size(), 8);
268261
269262 store->remove_atom(as, ha, true);
270263 store->close();
271264 as->extract_atom(ha, true);
272265 store->open();
273266 store->load_atomspace();
274 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
275 if (tvk) as->extract_atom(tvk);
276 TS_ASSERT_EQUALS(as->get_size(), 2);
267 // +1 for *-IsKeyFlag-*
268 TS_ASSERT_EQUALS(as->get_size(), 4);
277269
278270 // --------------------------------------
279271 store->erase();
……@@ -313,8 +305,8 @@ void BasicDeleteUTest::test_key_deletion(void)
313305 store->store_atom(ha);
314306 store->barrier();
315307
316 // Verify the atomspace size
317 TS_ASSERT_EQUALS(as->get_size(), 5);
308 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
309 TS_ASSERT_EQUALS(as->get_size(), 6);
318310
319311 // Verify that there are three keys
320312 HandleSet hs = ha->getKeys();
……@@ -325,7 +317,8 @@ void BasicDeleteUTest::test_key_deletion(void)
325317 // Remove one of the keys
326318 store->remove_atom(as, kb);
327319 as->extract_atom(kb);
328 TS_ASSERT_EQUALS(as->get_size(), 4);
320 // +1 for *-IsKeyFlag-*
321 TS_ASSERT_EQUALS(as->get_size(), 5);
329322
330323 // Verify the key was deleted by loading only PredicateNodes.
331324 as = createAtomSpace();
……@@ -357,10 +350,10 @@ void BasicDeleteUTest::test_key_deletion(void)
357350 store->open();
358351 TS_ASSERT(store->connected())
359352
360 // We expect 5 keys, including the truth-value key.
353 // We expect 6 keys (includes *-TruthValueKey-* and *-IsKeyFlag-*)
361354 printf("Loading the atomspace ...\n");
362355 store->load_atomspace();
363 TS_ASSERT_EQUALS(as->get_size(), 5);
356 TS_ASSERT_EQUALS(as->get_size(), 6);
364357
365358 // Verify that there are only two keys .. haha no, three.
366359 // That is because the deleted key gets restored when the
……@@ -415,13 +408,14 @@ void BasicDeleteUTest::test_key_corruption(void)
415408 store->store_atom(hb);
416409 store->barrier();
417410
418 // Verify the atomspace size
419 TS_ASSERT_EQUALS(as->get_size(), 4);
411 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
412 TS_ASSERT_EQUALS(as->get_size(), 5);
420413
421414 // Remove the value
422415 store->remove_atom(as, hx);
423416 as->extract_atom(hx);
424 TS_ASSERT_EQUALS(as->get_size(), 3);
417 // +1 for *-IsKeyFlag-*
418 TS_ASSERT_EQUALS(as->get_size(), 4);
425419
426420 // FYI, we should call store->close() at this point, but we
427421 // don't, because ... most users forget to do this too.
……@@ -440,7 +434,7 @@ void BasicDeleteUTest::test_key_corruption(void)
440434 store->open();
441435 TS_ASSERT(store->connected())
442436
443 // We expect 4 keys (the truth-value key doesn't show up.)
437 // We expect 5 atoms: b, x, key-x, *-IsKeyFlag-*, StorageNode
444438 // That's because the (Concept "x") sitting in the Value
445439 // was never actually deleted; thus it is restored.
446440 printf("Loading the atomspace ...\n");
……@@ -451,10 +445,9 @@ void BasicDeleteUTest::test_key_corruption(void)
451445 for (const Handle& h: hset)
452446 printf("Atomspace contains h=%s\n", h->to_short_string().c_str());
453447
454 Handle tvk(as->get_node(PREDICATE_NODE, "*-TruthValueKey-*"));
455 if (tvk) as->extract_atom(tvk);
456 // Size stays at 4 because (Concept "x") cannot be deleted.
457 TS_ASSERT_EQUALS(as->get_size(), 4);
448 // Size is 5 because (Concept "x") cannot be deleted.
449 // +1 for *-IsKeyFlag-*
450 TS_ASSERT_EQUALS(as->get_size(), 5);
458451
459452 hb = as->add_node(CONCEPT_NODE, "b");
460453 hx = as->add_node(CONCEPT_NODE, "x");
……@@ -467,19 +460,20 @@ void BasicDeleteUTest::test_key_corruption(void)
467460 store->store_atom(hb);
468461 store->barrier();
469462
470 TS_ASSERT_EQUALS(as->get_size(), 6);
463 // +1 for *-IsKeyFlag-*
464 TS_ASSERT_EQUALS(as->get_size(), 7);
471465
472466 // Remove the value .. again
473467 store->remove_atom(as, hx);
474468 as->extract_atom(hx);
475 TS_ASSERT_EQUALS(as->get_size(), 5);
469 // +1 for *-IsKeyFlag-*
470 TS_ASSERT_EQUALS(as->get_size(), 6);
476471 store->close();
477472 store->open();
478473 store->load_atomspace();
479 tvk = as->get_node(PREDICATE_NODE, "*-TruthValueKey-*");
480 if (tvk) as->extract_atom(tvk);
481 // Size stays at 6 because (Concept "x") cannot be deleted.
482 TS_ASSERT_EQUALS(as->get_size(), 6);
474 // Size is 7 because (Concept "x") cannot be deleted.
475 // +1 for *-IsKeyFlag-*
476 TS_ASSERT_EQUALS(as->get_size(), 7);
483477
484478 // We are done.
485479 store->close();
……@@ -496,10 +490,10 @@ void BasicDeleteUTest::test_key_corruption(void)
496490 store->open();
497491 TS_ASSERT(store->connected())
498492
499 // We expect 6 keys, (the truth-value key does not show.)
493 // We expect 7 atoms (+1 for *-IsKeyFlag-*)
500494 printf("Loading the atomspace ...\n");
501495 store->load_atomspace();
502 TS_ASSERT_EQUALS(as->get_size(), 6);
496 TS_ASSERT_EQUALS(as->get_size(), 7);
503497
504498 // Verify that there are two keys
505499 hb = as->add_node(CONCEPT_NODE, "b");
tests/persist/cog-storage/BasicSaveUTest.cxxtest +2 -2
……@@ -426,8 +426,8 @@ void BasicSaveUTest::test_table()
426426 size_t num_fetched = table2->get_size();
427427 printf("test_table: Done loading table; fetched %lu, expected %lu\n",
428428 num_fetched, num_stored);
429 // One extra, for the (PredicateNode "*-TruthValueKey-*")
430 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+1);
429 // Two extra: (PredicateNode "*-TruthValueKey-*") and (PredicateNode "*-IsKeyFlag-*")
430 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+2);
431431
432432 idx = 0;
433433 check_table(idx++, table2, "aaa ");
tests/persist/cog-storage/DeleteUTest.cxxtest +11 -8
……@@ -453,6 +453,7 @@ void DeleteUTest::test_remove(void)
453453 /* Push all atoms out to storage */
454454 store->store_atomspace();
455455
456 // +1 for (Predicate "*-IsKeyFlag-*")
456457 printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+1);
457458 TSM_ASSERT("Initial unexpected atomspace size",
458459 ((unsigned)(7*idx+1)) == _as->get_size());
……@@ -465,6 +466,7 @@ void DeleteUTest::test_remove(void)
465466 for (i=0; i<idx; i++)
466467 extract_links(i, _as);
467468
469 // +1 for (Predicate "*-IsKeyFlag-*")
468470 printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+1);
469471 TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+1)) == _as->get_size());
470472
……@@ -478,9 +480,9 @@ void DeleteUTest::test_remove(void)
478480 for (i=0; i<idx; i++)
479481 delete_links(i, store);
480482
481 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+2);
483 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3);
482484 TSM_ASSERT("Post-remove unexpected atomspace size",
483 ((unsigned)(4*idx+2)) == _as->get_size());
485 ((unsigned)(4*idx+3)) == _as->get_size());
484486
485487 /* Verify that the atoms are really gone from storage. */
486488 for (i=0; i<idx; i++) {
……@@ -488,9 +490,9 @@ void DeleteUTest::test_remove(void)
488490 check_remove(i, _as, "verify-gone");
489491 }
490492
491 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+2);
493 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3);
492494 TSM_ASSERT("Post-refetch unexpected atomspace size",
493 ((unsigned)(7*idx+2)) == _as->get_size());
495 ((unsigned)(7*idx+3)) == _as->get_size());
494496
495497 /* Kill data for good */
496498 _as->clear();
……@@ -544,6 +546,7 @@ void DeleteUTest::test_recurse(void)
544546 for (i=0; i<zap; i++)
545547 extract_nodes(i, _as);
546548
549 // +1 for the *-IsKeyFlag-* predicate
547550 size_t expsz = 7*(idx-zap) + 3*zap + 1;
548551 printf("Atomspace size=%lu expect=%lu\n",
549552 _as->get_size(), expsz);
……@@ -560,8 +563,8 @@ void DeleteUTest::test_recurse(void)
560563 delete_nodes(i, store);
561564
562565 printf("Post-remove size=%lu expect=%lu\n",
563 _as->get_size(), expsz+1);
564 TSM_ASSERT("Unexpected atomspace size", expsz+1 == _as->get_size());
566 _as->get_size(), expsz+2);
567 TSM_ASSERT("Unexpected atomspace size", expsz+2 == _as->get_size());
565568
566569 store->barrier();
567570
……@@ -571,9 +574,9 @@ void DeleteUTest::test_recurse(void)
571574 }
572575
573576 printf("Post-refetch size=%lu expect=%d\n",
574 _as->get_size(), 7*idx+2);
577 _as->get_size(), 7*idx+3);
575578 TSM_ASSERT("Unexpected atomspace size",
576 ((unsigned) 7*idx+2) == _as->get_size());
579 ((unsigned) 7*idx+3) == _as->get_size());
577580
578581 /* Check that the removed atoms really got zapped. */
579582 for (i=0; i<zap; i++) {
tests/persist/cog-storage/ValueSaveUTest.cxxtest +14 -11
……@@ -357,12 +357,12 @@ void ValueSaveUTest::test_load_by_type()
357357 store->fetch_all_atoms_of_type(CONCEPT_NODE);
358358 store->barrier();
359359
360 // Six: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*"
361 // and PredicateNode "some pred key" -- the two preds show up
362 // when the attached values are fetched.
363 printf ("fetched %lu atoms, expecting 7\n", as->get_size());
360 // Seven: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*",
361 // PredicateNode "some pred key", and PredicateNode "*-IsKeyFlag-*"
362 // -- the preds show up when the attached values are fetched.
363 printf ("fetched %lu atoms, expecting 8\n", as->get_size());
364364 // printf("contents=%s\n", as->to_string().c_str());
365 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 7);
365 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 8);
366366
367367 Handle gkey = as->add_node(PREDICATE_NODE, "some pred key");
368368 Handle gaf = as->add_node(CONCEPT_NODE, "float node");
……@@ -520,11 +520,12 @@ void ValueSaveUTest::test_link_by_type()
520520 // The B-nodes are added after the fetch. In either case,
521521 // there should not be any values fetched for either A or B;
522522 // only the values on the C-links should be fetched.
523 // +1 for (PredicateNode "*-IsKeyFlag-*")
523524 store->fetch_all_atoms_of_type(LIST_LINK);
524525 store->barrier();
525 printf ("fetched %lu atoms, expecting 15\n", as->get_size());
526 printf ("fetched %lu atoms, expecting 16\n", as->get_size());
526527 // printf("contents=%s\n", as->to_string().c_str());
527 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
528 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
528529
529530 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
530531 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -731,9 +732,10 @@ void ValueSaveUTest::test_link_by_type_quoted()
731732 store->fetch_all_atoms_of_type(LIST_LINK);
732733 store->barrier();
733734
734 // We created 9 new atoms above, so expect 15 from before plus 9
735 printf ("fetched %lu atoms, expecting 24\n", as->get_size());
736 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 24);
735 // We created 9 new atoms above, so expect 16 from before plus 9
736 // (+1 for *-IsKeyFlag-*)
737 printf ("fetched %lu atoms, expecting 25\n", as->get_size());
738 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25);
737739
738740 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
739741 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -945,7 +947,8 @@ void ValueSaveUTest::test_incoming()
945947 store->fetch_incoming_set(gal, false);
946948 store->fetch_incoming_set(gav, false);
947949 store->barrier();
948 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
950 // +1 for *-IsKeyFlag-*
951 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
949952
950953 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
951954 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");