/*
* tests/atoms/MemberLinkUTest.cxxtest
*
* Copyright (C) 2020 Linas Vepstas
* All Rights Reserved
*
* Author: Linas Vepstas
*
* 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 <opencog/atomspace/AtomSpace.h>
#include <opencog/atoms/execution/EvaluationLink.h>
using namespace opencog;
class MemberLinkUTest : public CxxTest::TestSuite
{
private:
AtomSpace _as;
public:
MemberLinkUTest()
{
logger().set_print_to_stdout_flag(true);
logger().set_timestamp_flag(false);
logger().set_sync_flag(true);
}
void setUp() {}
void tearDown() {}
void test_membership();
};
#define N _as.add_node
#define L _as.add_link
// Basic test
void MemberLinkUTest::test_membership()
{
logger().info("BEGIN TEST: %s", __FUNCTION__);
Handle A = N(CONCEPT_NODE, "A");
Handle B = N(CONCEPT_NODE, "B");
Handle C = N(CONCEPT_NODE, "C");
Handle D = N(CONCEPT_NODE, "D");
Handle S = L(SET_LINK, {A, B, C});
Handle AS = L(MEMBER_LINK, {A, S});
Handle DS = L(MEMBER_LINK, {D, S});
bool result = AS->bevaluate();
printf("Got result=%s\n", result ? "true" : "false");
TS_ASSERT(result);
result = DS->bevaluate();
TS_ASSERT(not result);
logger().info("END TEST: %s", __FUNCTION__);
}