View Javadoc

1   package de.bwaldvogel.liblinear;
2   
3   import static org.fest.assertions.Assertions.assertThat;
4   
5   import org.junit.Test;
6   
7   
8   public class FeatureNodeTest {
9   
10      public void testConstructorIndexZero() {
11          // since 1.5 there's no more exception here
12          new FeatureNode(0, 0);
13      }
14  
15      @Test(expected = IllegalArgumentException.class)
16      public void testConstructorIndexNegative() {
17          new FeatureNode(-1, 0);
18      }
19  
20      public void testConstructorHappy() {
21          FeatureNode fn = new FeatureNode(25, 27.39);
22          assertThat(fn.index).isEqualTo(25);
23          assertThat(fn.value).isEqualTo(27.39);
24  
25          fn = new FeatureNode(1, -0.22222);
26          assertThat(fn.index).isEqualTo(1);
27          assertThat(fn.value).isEqualTo(-0.22222);
28      }
29  }