gpt4 book ai didi

Java junit.framework.AssertionFailedError 错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:38:17 25 4
gpt4 key购买 nike

currentCapacity = queue.getCapacityLeft();

if(currentCapacity == queue.getCapacityLeft()) System.out.println("yes");

assertTrue( "Should have resized array",currentCapacity < queue.getCapacityLeft() );

这两个有2个不同的显示:第一个显示“yes”,这意味着当前容量等于queue.getCapacityLeft,但第二个也显示。

这是我的方法:

public int getCapacityLeft() { return 0; }

为什么我会遇到这个问题?

最佳答案

javadoc中指定的assertTrue方法表示该方法:

Asserts that a condition is true. If it isn't it throws an AssertionError with the given message.

因为条件currentCapacity < queue.getCapacityLeft()为 false 会抛出 AssertionError并打印消息“应该调整数组大小”,这就是您看到此消息也显示的原因。

关于Java junit.framework.AssertionFailedError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49268587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com