Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add NewWordTest #773

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/test/java/org/ansj/domain/NewWordTest.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
23 changes: 23 additions & 0 deletions src/test/java/org/ansj/domain/NumNatureAttrTest.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
7 changes: 7 additions & 0 deletions src/test/java/org/ansj/domain/ResultTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ansj.domain;

import org.ansj.splitWord.analysis.ToAnalysis;
import org.junit.Assert;
import org.junit.Test;

/**
Expand Down Expand Up @@ -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"), "");
}
}