Package aima.test.core.unit.logic.propositional.algorithms

Source Code of aima.test.core.unit.logic.propositional.algorithms.KnowledgeBaseTest

package aima.test.core.unit.logic.propositional.algorithms;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import aima.core.logic.propositional.algorithms.KnowledgeBase;

/**
* @author Ravi Mohan
*
*/
public class KnowledgeBaseTest {
  private KnowledgeBase kb;

  @Before
  public void setUp() {
    kb = new KnowledgeBase();
  }

  @Test
  public void testTellInsertsSentence() {
    kb.tell("(A AND B)");
    Assert.assertEquals(1, kb.size());
  }

  @Test
  public void testTellDoesNotInsertSameSentenceTwice() {
    kb.tell("(A AND B)");
    Assert.assertEquals(1, kb.size());
    kb.tell("(A AND B)");
    Assert.assertEquals(1, kb.size());
  }

  @Test
  public void testEmptyKnowledgeBaseIsAnEmptyString() {
    Assert.assertEquals("", kb.toString());
  }

  @Test
  public void testKnowledgeBaseWithOneSentenceToString() {
    kb.tell("(A AND B)");
    Assert.assertEquals(" ( A AND B )", kb.toString());
  }

  @Test
  public void testKnowledgeBaseWithTwoSentencesToString() {
    kb.tell("(A AND B)");
    kb.tell("(C AND D)");
    Assert.assertEquals(" (  ( A AND B ) AND  ( C AND D ) )", kb.toString());
  }

  @Test
  public void testKnowledgeBaseWithThreeSentencesToString() {
    kb.tell("(A AND B)");
    kb.tell("(C AND D)");
    kb.tell("(E AND F)");
    Assert.assertEquals(
        " (  (  ( A AND B ) AND  ( C AND D ) ) AND  ( E AND F ) )",
        kb.toString());
  }
}
TOP

Related Classes of aima.test.core.unit.logic.propositional.algorithms.KnowledgeBaseTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.