【发布时间】:2017-09-14 16:22:52
【问题描述】:
我有这个签名的方法:
public char[] checkDouble(String s) {
int[] letters = new int[26];
for (int i = 0; i < s.length(); i++) {
letters[s.charAt(i) - 97]++;
}
char[] copyLoop = new char[26];
for (int i = 0; i < letters.length; i++) {
if (letters[i] > 1) {
char c = (char) (i + 97);
copyLoop[i] = c;
}
}
return copyLoop;
}
还有我的 Junit 测试用例:
public class DoubleCharTest {
private DoubleChar c;
@Before
public void before() {
c = new DoubleChar();
}
@Test
public void test1(){
char [] result = c.checkDouble("wallaby");
Assert.assertEquals("al", result);
}
为什么我的测试没有通过并且出现这个错误?
expected: 'al' but was:<[C@3d075dc0>
【问题讨论】:
标签: java arrays unit-testing junit char