OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-storage / tests / persist / tlb / TLBUTest.cxxtest

68 lines · cxxtest ref:
/*
 * tests/persist/tlb/TLBUTest.cxxtest
 *
 * Copyright (C) 2011 OpenCog Foundation
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License v3 as
 * published by the Free Software Foundation and including the exceptions
 * at http://opencog.org/wiki/Licenses
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, write to:
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <iostream>
#include <fstream>
#include <streambuf>
#include <stdio.h>

#include <opencog/atoms/base/Node.h>
#include <opencog/persist/tlb/TLB.h>
#include <opencog/atoms/atom_types/atom_types.h>
#include <opencog/util/exceptions.h>

using namespace opencog;
using namespace std;

class TLBUTest :  public CxxTest::TestSuite
{
private:

public:
    TLBUTest() {
    }

    void setUp() {
    }

    void tearDown() {
    }

    void testAdd() {

        TLB tlb;

        Handle n(createNode(CONCEPT_NODE, "test"));
        UUID uuid = tlb.addAtom(n, TLB::INVALID_UUID);
        TS_ASSERT(TLB::INVALID_UUID != uuid);

        Handle nb(createNode(CONCEPT_NODE, "test"));

        // content-compare should work
        TS_ASSERT( *n == *nb);

        UUID uuidb = tlb.addAtom(nb, TLB::INVALID_UUID);
        printf("expected: %zu got: %zu\n", uuid, uuidb);
        TS_ASSERT(uuidb == uuid);
    }
};