From cc75ef7b90801aed4b895af116561d756552ed21 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Tue, 22 Sep 2020 12:13:23 +0800 Subject: [PATCH] add NewWordTest --- .../java/org/ansj/domain/NewWordTest.java | 46 +++++++++++++++++++ .../org/ansj/domain/NumNatureAttrTest.java | 23 ++++++++++ src/test/java/org/ansj/domain/ResultTest.java | 7 +++ 3 files changed, 76 insertions(+) create mode 100644 src/test/java/org/ansj/domain/NewWordTest.java create mode 100644 src/test/java/org/ansj/domain/NumNatureAttrTest.java diff --git a/src/test/java/org/ansj/domain/NewWordTest.java b/src/test/java/org/ansj/domain/NewWordTest.java new file mode 100644 index 00000000..a4d28bad --- /dev/null +++ b/src/test/java/org/ansj/domain/NewWordTest.java @@ -0,0 +1,46 @@ +package org.ansj.domain; + +import org.junit.Assert; +import org.junit.Test; + + +public class NewWordTest { + + @Test + public void test1() { + NewWord newWord = new NewWord("a", Nature.NW, 1.0); + System.out.println(newWord.getName()); + Assert.assertEquals(newWord.getName(), "a"); + } + + @Test + public void test2() { + NewWord newWord = new NewWord("a", Nature.NW); + newWord.setName("a1"); + System.out.println(newWord.getName()); + Assert.assertEquals(newWord.getName(), "a1"); + } + + @Test + public void test3() { + NewWord newWord = new NewWord("a", Nature.NW); + newWord.setNature(Nature.NULL); + System.out.println(newWord.getNature().toString()); + Assert.assertEquals(newWord.getNature().toString(), "null:-1:-1"); + } + + @Test + public void test4() { + NewWord newWord = new NewWord("a", Nature.NW); + newWord.update(Nature.NULL, 1); + System.out.println(newWord.getNature().toString()); + Assert.assertEquals(newWord.getNature().toString(), "null:-1:-1"); + } + + @Test + public void test5() { + NewWord newWord = new NewWord("a", Nature.NW); + System.out.println(newWord.toString()); + Assert.assertEquals(newWord.toString(), "a 0.0 nw"); + } +} diff --git a/src/test/java/org/ansj/domain/NumNatureAttrTest.java b/src/test/java/org/ansj/domain/NumNatureAttrTest.java new file mode 100644 index 00000000..f440e340 --- /dev/null +++ b/src/test/java/org/ansj/domain/NumNatureAttrTest.java @@ -0,0 +1,23 @@ +package org.ansj.domain; + +import org.junit.Assert; +import org.junit.Test; + + +public class NumNatureAttrTest { + + @Test + public void test1() { + NumNatureAttr numNatureAttr = new NumNatureAttr(false, true, "a"); + System.out.println(numNatureAttr.getNature()); + Assert.assertEquals(numNatureAttr.getNature().toString(), "a:2:2"); + } + + @Test + public void test2() { + NumNatureAttr numNatureAttr = new NumNatureAttr(true, true, "b"); + numNatureAttr.setQua(false); + System.out.println(numNatureAttr.isQua()); + Assert.assertFalse(numNatureAttr.isQua()); + } +} diff --git a/src/test/java/org/ansj/domain/ResultTest.java b/src/test/java/org/ansj/domain/ResultTest.java index 194ba2df..ac86aec3 100644 --- a/src/test/java/org/ansj/domain/ResultTest.java +++ b/src/test/java/org/ansj/domain/ResultTest.java @@ -1,6 +1,7 @@ package org.ansj.domain; import org.ansj.splitWord.analysis.ToAnalysis; +import org.junit.Assert; import org.junit.Test; /** @@ -32,4 +33,10 @@ public void toStringWithOutNatureSplitTest() { System.out.println(ToAnalysis.parse("分词结果!").toStringWithOutNature("\t")); } + @Test + public void test1() { + Result result = new Result(null); + System.out.println(result.toStringWithOutNature("a")); + Assert.assertEquals(result.toStringWithOutNature("a"), ""); + } }