Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6139

[classlib][luni][java6] java.util.Arrays.binarySearch(short[] array, int startIndex, int endIndex, short value) should return (-(insertion point) - 1) rather than -1 if value is not found in the given range

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0M8
    • 5.0M9
    • Classlib
    • None
    • Moderate

    Description

      Given a test case [1] below, RI passes while HY6 fails.
      The testcase is used to test the binarySearch(short[] array, int startIndex, int endIndex, short value) of java.util.Arrays class.
      According to java spec, if the given value is not found in the given range of array, this method should return (-(insertion point) - 1) rather than -1.
      Here, "insertion point" is defined as the point at which the key would be inserted into the array or endIndex if all elements in the range are less than the specified key. And HY6 doesn't implement this.

      [1] Test Case:
      public void test_Arrays_binaraySearch_short() {
      assertEquals(-2, Arrays.binarySearch(new short[]

      { (short) -1 }

      , 1, 1, (short)0));
      }

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--Harmony6139_v3.diff
          10 kB
          Ray Chen
        2. Harmony6139_v2.diff
          11 kB
          Ray Chen
        3. Harmony6139.diff
          11 kB
          Ray Chen

        Activity

          People

            zhoukevin Kevin Zhou
            zhoukevin Kevin Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: