< prev index next >

test/jdk/java/util/Collections/BinarySearchNullComparator.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 23,20 ***
--- 23,28 ---
  
  /*
   * @test
   * @bug 4528331 5006032
   * @summary Test Collections.binarySearch() with a null comparator
+  * @library /test/lib
   */
  
+ import jdk.test.lib.valueclass.VClass;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.List;
  
  public class BinarySearchNullComparator {
+ 
      public static void main(String[] args) throws Exception {
          List list = Arrays.asList(new String[] {"I", "Love", "You"});
  
          int result = Collections.binarySearch(list, "You", null);
          if (result != 2)
              throw new Exception("Result: " + result);
+ 
+         List<VClass> values = Arrays.asList(new VClass(1, new int[] { 1 }), new VClass(2, new int[] { 2 }), new VClass(3, new int[] { 3 }));
+         int vresult = Collections.binarySearch(values, new VClass(3, new int[] { 3 }), null);
+         if (vresult != 2)
+             throw new Exception("Value result: " + vresult);
      }
  }
< prev index next >