| … | … | @@ -32,9 +32,11 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> |
| 35 | 36 | |
| 36 | 37 | #include <opencog/atomspace/AtomSpace.h> |
| 37 | 38 | |
| 39 | #include <opencog/persist/api/StorageNode.h> |
| 38 | 40 | #include <opencog/persist/rocks-types/atom_types.h> |
| 39 | 41 | #include <opencog/persist/monospace/MonoStorage.h> |
| 40 | 42 | |
| … | … | @@ -45,7 +47,7 @@ using namespace opencog; |
| 45 | 47 | class PersistUTest : public CxxTest::TestSuite |
| 46 | 48 | { |
| 47 | 49 | private: |
| 48 | | AtomSpace *_as; |
| 50 | AtomSpacePtr _as; |
| 49 | 51 | |
| 50 | 52 | NodePtr n1[10]; |
| 51 | 53 | NodePtr n2[10]; |
| … | … | @@ -100,12 +102,12 @@ PersistUTest:: PersistUTest(void) |
| 100 | 102 | */ |
| 101 | 103 | void PersistUTest::setUp(void) |
| 102 | 104 | { |
| 103 | | _as = new AtomSpace(); |
| 105 | _as = createAtomSpace(); |
| 104 | 106 | } |
| 105 | 107 | |
| 106 | 108 | void PersistUTest::tearDown(void) |
| 107 | 109 | { |
| 108 | | delete _as; |
| 110 | _as = nullptr; |
| 109 | 111 | } |
| 110 | 112 | |
| 111 | 113 | // ============================================================ |
| … | … | @@ -317,25 +319,25 @@ void PersistUTest::test_atomspace(void) |
| 317 | 319 | |
| 318 | 320 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest"); |
| 319 | 321 | StorageNodePtr store = StorageNodeCast(hsn); |
| 320 | | store->open(); |
| 322 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 321 | 323 | TS_ASSERT(store->connected()) |
| 322 | 324 | |
| 323 | 325 | 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 "); |
| 329 | 331 | |
| 330 | 332 | /* 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(), "係拉丁字母"); |
| 334 | 336 | |
| 335 | 337 | /* Verify that the atoms were added */ |
| 336 | 338 | int i; |
| 337 | 339 | for (i=0; i<idx; i++) |
| 338 | | check_space(i, _as, "verify-add"); |
| 340 | check_space(i, _as.get(), "verify-add"); |
| 339 | 341 | |
| 340 | 342 | /* Push all atoms out to the Cogserver */ |
| 341 | 343 | store->store_atomspace(); |
| … | … | @@ -351,12 +353,12 @@ void PersistUTest::test_atomspace(void) |
| 351 | 353 | /* The above clear wiped out the storage node; recreate it. */ |
| 352 | 354 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest"); |
| 353 | 355 | store = StorageNodeCast(hsn); |
| 354 | | store->open(); |
| 356 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 355 | 357 | |
| 356 | 358 | /* Verify that the atoms can still be fetched from storage. */ |
| 357 | 359 | for (i=0; i<idx; i++) { |
| 358 | 360 | fetch_space(i, store); |
| 359 | | check_space(i, _as, "verify-fetch"); |
| 361 | check_space(i, _as.get(), "verify-fetch"); |
| 360 | 362 | } |
| 361 | 363 | |
| 362 | 364 | /* Do it again, for good luck. */ |
| … | … | @@ -366,12 +368,12 @@ void PersistUTest::test_atomspace(void) |
| 366 | 368 | /* The above clear wiped out the storage node; recreate it. */ |
| 367 | 369 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-persist-utest"); |
| 368 | 370 | store = StorageNodeCast(hsn); |
| 369 | | store->open(); |
| 371 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 370 | 372 | |
| 371 | 373 | /* Verify that the atoms can still be fetched from storage. */ |
| 372 | 374 | for (i=0; i<idx; i++) { |
| 373 | 375 | fetch_space(i, store); |
| 374 | | check_space(i, _as, "ver-again"); |
| 376 | check_space(i, _as.get(), "ver-again"); |
| 375 | 377 | } |
| 376 | 378 | |
| 377 | 379 | /* Kill data for good */ |
| … | … | @@ -380,7 +382,7 @@ void PersistUTest::test_atomspace(void) |
| 380 | 382 | |
| 381 | 383 | /* Verify that the atoms are no longer being found. */ |
| 382 | 384 | for (i=0; i<idx; i++) |
| 383 | | check_empty(i, _as); |
| 385 | check_empty(i, _as.get()); |
| 384 | 386 | |
| 385 | 387 | logger().debug("END TEST: %s", __FUNCTION__); |
| 386 | 388 | } |