OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-rocks commits / 37fe99f

Port over another unit test
37fe99fad68c16da318aa96585dd60e53c18e69e
by Linas Vepstas <linasvepstas@gmail.com> · 2026-01-18T23:46:20.000Z

Changed files (1) +20 -18

tests/persist/monospace/MonoPersistUTest.cxxtest +20 -18
……@@ -32,9 +32,11 @@
3232#include <opencog/atoms/base/Link.h>
3333#include <opencog/atoms/base/Node.h>
3434#include <opencog/atoms/value/FloatValue.h>
35#include <opencog/atoms/value/VoidValue.h>
3536
3637#include <opencog/atomspace/AtomSpace.h>
3738
39#include <opencog/persist/api/StorageNode.h>
3840#include <opencog/persist/rocks-types/atom_types.h>
3941#include <opencog/persist/monospace/MonoStorage.h>
4042
……@@ -45,7 +47,7 @@ using namespace opencog;
4547class PersistUTest : public CxxTest::TestSuite
4648{
4749 private:
48 AtomSpace *_as;
50 AtomSpacePtr _as;
4951
5052 NodePtr n1[10];
5153 NodePtr n2[10];
……@@ -100,12 +102,12 @@ PersistUTest:: PersistUTest(void)
100102 */
101103void PersistUTest::setUp(void)
102104{
103 _as = new AtomSpace();
105 _as = createAtomSpace();
104106}
105107
106108void PersistUTest::tearDown(void)
107109{
108 delete _as;
110 _as = nullptr;
109111}
110112
111113// ============================================================
……@@ -317,25 +319,25 @@ void PersistUTest::test_atomspace(void)
317319
318320 Handle hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest");
319321 StorageNodePtr store = StorageNodeCast(hsn);
320 store->open();
322 store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue());
321323 TS_ASSERT(store->connected())
322324
323325 int idx = 0;
324 add_to_space(idx++, _as, "AA-aa-wow ");
325 add_to_space(idx++, _as, "BB-bb-wow ");
326 add_to_space(idx++, _as, "CC-cc-wow ");
327 add_to_space(idx++, _as, "DD-dd-wow ");
328 add_to_space(idx++, _as, "EE-ee-wow ");
326 add_to_space(idx++, _as.get(), "AA-aa-wow ");
327 add_to_space(idx++, _as.get(), "BB-bb-wow ");
328 add_to_space(idx++, _as.get(), "CC-cc-wow ");
329 add_to_space(idx++, _as.get(), "DD-dd-wow ");
330 add_to_space(idx++, _as.get(), "EE-ee-wow ");
329331
330332 /* Make sure UTF-8 works fine. */
331 add_to_space(idx++, _as, "Попытка выбраться вызвала слабый стон ");
332 add_to_space(idx++, _as, "はにがうりだそうであってるのかはち ");
333 add_to_space(idx++, _as, "係拉丁字母");
333 add_to_space(idx++, _as.get(), "Попытка выбраться вызвала слабый стон ");
334 add_to_space(idx++, _as.get(), "はにがうりだそうであってるのかはち ");
335 add_to_space(idx++, _as.get(), "係拉丁字母");
334336
335337 /* Verify that the atoms were added */
336338 int i;
337339 for (i=0; i<idx; i++)
338 check_space(i, _as, "verify-add");
340 check_space(i, _as.get(), "verify-add");
339341
340342 /* Push all atoms out to the Cogserver */
341343 store->store_atomspace();
……@@ -351,12 +353,12 @@ void PersistUTest::test_atomspace(void)
351353 /* The above clear wiped out the storage node; recreate it. */
352354 hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest");
353355 store = StorageNodeCast(hsn);
354 store->open();
356 store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue());
355357
356358 /* Verify that the atoms can still be fetched from storage. */
357359 for (i=0; i<idx; i++) {
358360 fetch_space(i, store);
359 check_space(i, _as, "verify-fetch");
361 check_space(i, _as.get(), "verify-fetch");
360362 }
361363
362364 /* Do it again, for good luck. */
……@@ -366,12 +368,12 @@ void PersistUTest::test_atomspace(void)
366368 /* The above clear wiped out the storage node; recreate it. */
367369 hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest");
368370 store = StorageNodeCast(hsn);
369 store->open();
371 store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue());
370372
371373 /* Verify that the atoms can still be fetched from storage. */
372374 for (i=0; i<idx; i++) {
373375 fetch_space(i, store);
374 check_space(i, _as, "ver-again");
376 check_space(i, _as.get(), "ver-again");
375377 }
376378
377379 /* Kill data for good */
……@@ -380,7 +382,7 @@ void PersistUTest::test_atomspace(void)
380382
381383 /* Verify that the atoms are no longer being found. */
382384 for (i=0; i<idx; i++)
383 check_empty(i, _as);
385 check_empty(i, _as.get());
384386
385387 logger().debug("END TEST: %s", __FUNCTION__);
386388}