level 1
oltage
楼主
下面这个测试代码怎么错了
#include "stdafx.h"
#include "CppUnitTest.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest1Add
{
TEST_CLASS(Add)
{
public:
TEST_METHOD(sum)
{
int num1 = 100, num2 = 200;
Assert .AreEqual(Add.sum(num1, num2), 300);
}
};
}
这是要被测试的代码:
#include "stdafx.h"
using namespace std;
class Add {
public:
int sum(int x, int y);
private:
int x, y;
};
int Add::sum(int x, int y) {
return x + y;
}
int main() {
Add add;
add.sum(1, 2);
return 0;
}
2017年05月02日 04点05分
1
#include "stdafx.h"
#include "CppUnitTest.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest1Add
{
TEST_CLASS(Add)
{
public:
TEST_METHOD(sum)
{
int num1 = 100, num2 = 200;
Assert .AreEqual(Add.sum(num1, num2), 300);
}
};
}
这是要被测试的代码:
#include "stdafx.h"
using namespace std;
class Add {
public:
int sum(int x, int y);
private:
int x, y;
};
int Add::sum(int x, int y) {
return x + y;
}
int main() {
Add add;
add.sum(1, 2);
return 0;
}