コード例 #1
0
 @Test
 public void test4() {
   MyObject mo = new MyObject();
   mo.str = "test4";
   List<Object> list = new ArrayList<Object>();
   list.add(mo);
   TestUtil.sp(list);
   TestUtil.sp(list.toArray(new String[] {}));
 }
コード例 #2
0
 /** Test: Can String in Object be modified by reference? Result: Yes */
 @Test
 public void test1() {
   ArrayList<MyObject> mys = new ArrayList<ListTest.MyObject>();
   MyObject mo = new MyObject();
   mo.str = "init set";
   mys.add(mo);
   TestUtil.sp(mys);
   mo.str = "first set";
   TestUtil.sp(mys);
 }
コード例 #3
0
 /**
  * Test: Can parameter modified by Method? Result: Properties can be modified, but can't set
  * parameter to null
  */
 @Test
 public void test3() {
   MyObject mo = new MyObject();
   mo.str = "lala";
   TestUtil.sp("Init - " + mo);
   test3_method(mo);
   TestUtil.sp("Change Property - " + mo);
   mo.str = "tonull";
   test3_method(mo);
   TestUtil.sp("Set Object to null - " + mo);
 }
コード例 #4
0
 /** Test: Can enum in Object be modified by reference? Result: No, value type */
 @Test
 public void test2() {
   MyObject mo = new MyObject();
   mo.type = MyType.T1;
   TestUtil.sp(mo);
   @SuppressWarnings("unused")
   MyType t = mo.type;
   t = null;
   TestUtil.sp(mo);
   t = MyType.T2;
   TestUtil.sp(mo);
 }
コード例 #5
0
 public void test3_method(MyObject obj) {
   if (obj.str.equals("tonull")) {
     TestUtil.sp("set obj to null");
     obj = null;
   } else {
     obj.str = "changed";
   }
 }
コード例 #6
0
  @Test
  public void sortT5() {
    List<MyObject> mol =
        ListUtil.newArrayList(new MyObject("b"), new MyObject("a"), new MyObject("c"));
    TestUtil.sp(mol);
    Collections.sort(mol, new MyObjectComparator());
    TestUtil.sp(mol);

    //        List<String> listNull = null;
    //        Collections.sort(listNull);
    //        TestUtil.sp(listNull);

    List<String> list = ListUtil.newArrayList("1");
    Iterator<String> it = list.iterator();
    TestUtil.sp("First : " + it.next());
    TestUtil.sp("Second: " + it.next());
  }