我们来做点unit test吧,座位数从3000改为4# Programming - 葵花宝典
w*w
1 楼
看看bug都改正后的性能怎样。
Test case 1:
static void test1() {
testReserve(0, 3, 7);
testReserve(0, 0, 2);
testReserve(0, 2, 8);
testReserve(0, 0, 3);
testReserve(0, 0, 10);
testReserve(0, 0, 10);
}
Reserving Start=3 Length=7
Succeed number=1 start=0 length=10
Reserving Start=0 Length=2
Succeed number=1 start=0 length=3
Reserving Start=2 Length=8
Succeed number=2 start=0 length=10
Reserving Start=0 Length=3
Succeed number=3 start=0 length=10
Reserving Start=0 Length=10
Succeed number=4 start=0 length=10
Reserving Start=0 Length=10
Failed
问题:票长度不对,start也不对。
Test case 1:
static void test1() {
testReserve(0, 3, 7);
testReserve(0, 0, 2);
testReserve(0, 2, 8);
testReserve(0, 0, 3);
testReserve(0, 0, 10);
testReserve(0, 0, 10);
}
Reserving Start=3 Length=7
Succeed number=1 start=0 length=10
Reserving Start=0 Length=2
Succeed number=1 start=0 length=3
Reserving Start=2 Length=8
Succeed number=2 start=0 length=10
Reserving Start=0 Length=3
Succeed number=3 start=0 length=10
Reserving Start=0 Length=10
Succeed number=4 start=0 length=10
Reserving Start=0 Length=10
Failed
问题:票长度不对,start也不对。