/** 値の取得。 */ @Test public void get() { ShortOption option = new ShortOption(); option.modify((short) 100); assertThat(option.get(), is((short) 100)); assertThat(option.isNull(), is(false)); }
/** 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())); }
/** Writableのテスト。 */ @Test public void write() { ShortOption option = new ShortOption(); option.modify((short) 100); ShortOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** 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)); }
/** 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)); }
/** 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)); }
/** 比較のテスト。 */ @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)); }
/** すでに値が設定された状態のor。 */ @Test public void orNotNull() { ShortOption option = new ShortOption(); option.modify((short) 100); assertThat(option.or((short) 30), is((short) 100)); }
/** nullに対するor。 */ @Test public void or() { ShortOption option = new ShortOption(); assertThat(option.or((short) 30), is((short) 30)); assertThat(option.isNull(), is(true)); }
/** 初期状態のテスト。 */ @Test public void init() { ShortOption option = new ShortOption(); assertThat(option.isNull(), is(true)); }
/** null-Writableのテスト。 */ @Test public void writeNull() { ShortOption option = new ShortOption(); ShortOption restored = restore(option); assertThat(restored.isNull(), is(true)); }