#include "stdafx.h" #include "CppUnitTest.h" #include "Windows.h" #include"../jia/jia.h" #include"../jian/jian.h" #include"../chen/chen.h" #include"../chu/chu.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; namespace UnitTest1 { TEST_CLASS(UnitTest1) { public: TEST_METHOD(TestMethod1) { // TODO: ÔÚ´ËÊäÈë²âÊÔ´úÂë int SUM = GetPrivateProfileInt("Len", "sum", 0, "../ex1.ini"); { for (int i = 1; i <= SUM; i++) { char SUMStr[8]; char TestStr[8] = { "Test" }; _itoa_s(i, SUMStr, 8); strcat_s(TestStr, SUMStr); int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex1.ini"); int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex1.ini"); int output = GetPrivateProfileInt("TestStr", "output", 0, "ex1.ini"); Assert::AreEqual(output, add(num1, num2)); } } } TEST_METHOD(TestMethod2) { int SUB = GetPrivateProfileInt("Len", "sum", 0, "../ex2.ini"); { for (int j = 1; j <= SUB; j++) { char SUBStr[8]; char TestStr[8] = { "Test" }; _itoa_s(j, SUBStr, 8); strcat_s(TestStr, SUBStr); int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex2.ini"); int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex2.ini"); int output = GetPrivateProfileInt("TestStr", "output", 0, "ex2.ini"); Assert::AreEqual(output, sub(num1, num2)); } } } TEST_METHOD(TestMethod3) { int MUL = GetPrivateProfileInt("Len", "sum", 0, "../ex3.ini"); { for (int i = 1; i <= MUL; i++) { char MULStr[8]; char TestStr[8] = { "Test" }; _itoa_s(i, MULStr, 8); strcat_s(TestStr, MULStr); int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex3.ini"); int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex3.ini"); int output = GetPrivateProfileInt("TestStr", "output", 0, "ex3.ini"); Assert::AreEqual(output, mul(num1, num2)); } } } TEST_METHOD(TestMethod4) { int DIV = GetPrivateProfileInt("Len", "sum", 0, "../ex4.ini"); { for (int i = 1; i <= DIV; i++) { char DIVStr[8]; char TestStr[8] = { "Test" }; _itoa_s(i, DIVStr, 8); strcat_s(TestStr, DIVStr); int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex4.ini"); int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex4.ini"); int output = GetPrivateProfileInt("TestStr", "output", 0, "ex4.ini"); Assert::AreEqual(output, chu(num1, num2)); } } } }; }