groovy

assertArrayEquals problem when multidimensional array

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-4
  • Fix Version/s: 1.0-JSR-6
  • Component/s: groovy-jdk
  • Labels:
    None
  • Environment:
    SuSE Linux 8.2, JDK 1.4.2
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

Testcase bellow throws exception

testArrayEquals(MultiArrayBugTest)junit.framework.AssertionFailedError: expected array: {"A", "B"} value array: {["A", "C"]} expected:<2> but was:<1>.

// ------------------- MultiArrayClass.java -------------------
public class MultiArrayClass {
public String[][] createArray() { String s[][] = new String[2][2]; s [0][0] = "A"; s [0][1] = "C"; s [1][0] = "C"; s [1][1] = "D"; return s; }
}

// ----------------- MultiArrayBugTest.groovy -----------------
class MultiArrayBugTest extends GroovyTestCase {
void testArrayEquals() { def m = new MultiArrayClass() def r = m.createArray() assertArrayEquals(['A','B'] as String[], r[0] as String[]); assertArrayEquals(['C','D'] as String[], r[1] as String[]); }
}

Activity

Hide
Russel Winder added a comment -

I assume the second assignment to s should be:

s[0][1] = "B" ;

Running this on CVS as of 2006-02-07 08:57 I got a slightly different error message:

testArrayEquals(MultiArrayBugTest)junit.framework.AssertionFailedError: expected array: {"A", "B"} value array: {"B"} expected:<2> but was:<1>

Show
Russel Winder added a comment - I assume the second assignment to s should be: s[0][1] = "B" ; Running this on CVS as of 2006-02-07 08:57 I got a slightly different error message: testArrayEquals(MultiArrayBugTest)junit.framework.AssertionFailedError: expected array: {"A", "B"} value array: {"B"} expected:<2> but was:<1>
Hide
Russel Winder added a comment -

I should have added that I am using Ubuntu 5.10 Breezy Badger and Java SE 5 (JDK 1.5.0_06)

Show
Russel Winder added a comment - I should have added that I am using Ubuntu 5.10 Breezy Badger and Java SE 5 (JDK 1.5.0_06)
Hide
blackdrag blackdrag added a comment -

fixed now

Show
blackdrag blackdrag added a comment - fixed now

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: