Exemplo n.º 1
0
 /** 値の取得。 */
 @Test
 public void get() {
   ShortOption option = new ShortOption();
   option.modify((short) 100);
   assertThat(option.get(), is((short) 100));
   assertThat(option.isNull(), is(false));
 }
Exemplo n.º 2
0
 /** Writableのテスト。 */
 @Test
 public void write_min() {
   ShortOption option = new ShortOption();
   option.modify(Short.MIN_VALUE);
   ShortOption restored = restore(option);
   assertThat(restored.get(), is(option.get()));
 }
Exemplo n.º 3
0
 /** Writableのテスト。 */
 @Test
 public void write() {
   ShortOption option = new ShortOption();
   option.modify((short) 100);
   ShortOption restored = restore(option);
   assertThat(restored.get(), is(option.get()));
 }
Exemplo n.º 4
0
  /** nullに関する順序付けのテスト。 */
  @Test
  public void compareNull() {
    ShortOption a = new ShortOption();
    ShortOption b = new ShortOption();
    ShortOption c = new ShortOption();

    a.modify((short) 0x8000);

    assertThat(compare(a, b), greaterThan(0));
    assertThat(compare(b, a), lessThan(0));
    assertThat(compare(b, c), is(0));
  }
Exemplo n.º 5
0
  /** copyFromのテスト。 */
  @Test
  public void copy() {
    ShortOption option = new ShortOption();
    ShortOption other = new ShortOption();
    other.modify((short) 50);
    option.copyFrom(other);
    assertThat(option.get(), is((short) 50));

    option.modify((short) 0);
    assertThat(other.get(), is((short) 50));
  }
Exemplo n.º 6
0
  /** copyFromにnullを指定するテスト。 */
  @Test
  public void copyNull() {
    ShortOption option = new ShortOption();
    option.modify((short) 100);

    ShortOption other = new ShortOption();
    option.copyFrom(other);
    assertThat(option.isNull(), is(true));
    option.modify((short) 100);

    option.copyFrom(null);
    assertThat(option.isNull(), is(true));
  }
Exemplo n.º 7
0
  /** 比較のテスト。 */
  @Test
  public void compareTo() {
    ShortOption a = new ShortOption();
    ShortOption b = new ShortOption();
    ShortOption c = new ShortOption();
    ShortOption d = new ShortOption();

    a.modify((short) -10);
    b.modify((short) 0);
    c.modify((short) 30);
    d.modify((short) -10);

    assertThat(compare(a, b), lessThan(0));
    assertThat(compare(b, c), lessThan(0));
    assertThat(compare(c, a), greaterThan(0));
    assertThat(compare(a, c), lessThan(0));
    assertThat(compare(b, a), greaterThan(0));
    assertThat(compare(c, b), greaterThan(0));
    assertThat(compare(a, d), is(0));
  }
Exemplo n.º 8
0
 /** すでに値が設定された状態のor。 */
 @Test
 public void orNotNull() {
   ShortOption option = new ShortOption();
   option.modify((short) 100);
   assertThat(option.or((short) 30), is((short) 100));
 }
Exemplo n.º 9
0
 /** nullに対するor。 */
 @Test
 public void or() {
   ShortOption option = new ShortOption();
   assertThat(option.or((short) 30), is((short) 30));
   assertThat(option.isNull(), is(true));
 }
Exemplo n.º 10
0
 /** 初期状態のテスト。 */
 @Test
 public void init() {
   ShortOption option = new ShortOption();
   assertThat(option.isNull(), is(true));
 }
Exemplo n.º 11
0
 /** null-Writableのテスト。 */
 @Test
 public void writeNull() {
   ShortOption option = new ShortOption();
   ShortOption restored = restore(option);
   assertThat(restored.isNull(), is(true));
 }