CPPUNIT_ASSERT_EQUAL(-1, add.Add(2, -3));
}
...
好了好了,我不会再写出愚蠢的代码,我会实现Add了。
...
// Add two numbers
int Add(int first, int second)
{
return first + second;
}
...
OK,用例又通过了,太好了。
当然,这不是一个好例子,因为测试和开发的步伐太过于细小了,不过用来说事倒是还算不错。好吧,还是让大家都来做一个小练习。
实现一个CPrime类,它的声明如下:
class CPrime
{
// Create a pool containing the primes less or equal the number "max"
// return true if create pool successfully, otherwise, return false
bool CreatePool(int max);
// Get a number from the pool
int GetPrime(int index);
文章来源于领测软件测试网 https://www.ltesting.net/