代码拉取完成,页面将自动刷新
import junit.framework.TestCase;
import org.junit.Test;
public class StringBufferDemoTest extends TestCase {
StringBuffer one = new StringBuffer("20175319help");//测试12个字符
StringBuffer two = new StringBuffer("123456789123456789123456");//测试24个字符
StringBuffer three = new StringBuffer("java is so good and fucking cool!!!");//测试35个字符
@Test
public void testcharAt() throws Exception {
assertEquals('2',one.charAt(0));
assertEquals('5',two.charAt(4));
assertEquals('!',three.charAt(34));
}
@Test
public void testcapacity() throws Exception {
assertEquals(28,one.capacity());
assertEquals(40,two.capacity());
assertEquals(51,three.capacity());
}
@Test
public void testlength() throws Exception {
assertEquals(12,one.length());
assertEquals(24,two.length());
assertEquals(35,three.length());
}
public void testindexOf() throws Exception {
assertEquals(0,one.indexOf("20175319"));
assertEquals(5,two.indexOf("678"));
assertEquals(-1,three.indexOf("!!!!"));
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。