diff --git a/jia/UnitTest1/UnitTest1.vcxproj b/jia/UnitTest1/UnitTest1.vcxproj new file mode 100644 index 0000000..9fecb53 --- /dev/null +++ b/jia/UnitTest1/UnitTest1.vcxproj @@ -0,0 +1,99 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {624E0933-6EC9-4441-B0E7-B91AD913A772} + Win32Proj + UnitTest1 + + + + DynamicLibrary + true + v120 + MultiByte + false + + + DynamicLibrary + false + v120 + true + Unicode + false + + + + + + + + + + + + + true + + + true + + + + Use + Level3 + Disabled + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + ..\jia\Debug\jia.obj;..\jian\Debug\jian.obj;..\chen\Debug\chen.obj;..\chu\Debug\chu.obj;%(AdditionalDependencies) + + + + + Level3 + Use + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + + + + + Create + Create + + + + + + + \ No newline at end of file diff --git a/jia/UnitTest1/UnitTest1.vcxproj.filters b/jia/UnitTest1/UnitTest1.vcxproj.filters new file mode 100644 index 0000000..11980ad --- /dev/null +++ b/jia/UnitTest1/UnitTest1.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/jia/UnitTest1/stdafx.cpp b/jia/UnitTest1/stdafx.cpp new file mode 100644 index 0000000..6051b53 --- /dev/null +++ b/jia/UnitTest1/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// UnitTest1.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/jia/UnitTest1/stdafx.h b/jia/UnitTest1/stdafx.h new file mode 100644 index 0000000..b8f24af --- /dev/null +++ b/jia/UnitTest1/stdafx.h @@ -0,0 +1,13 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +// CppUnitTest ͷļ +#include "CppUnitTest.h" + +// TODO: ڴ˴óҪͷļ diff --git a/jia/UnitTest1/targetver.h b/jia/UnitTest1/targetver.h new file mode 100644 index 0000000..c4ac7c0 --- /dev/null +++ b/jia/UnitTest1/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/jia/UnitTest1/unittest1.cpp b/jia/UnitTest1/unittest1.cpp new file mode 100644 index 0000000..7dff01e --- /dev/null +++ b/jia/UnitTest1/unittest1.cpp @@ -0,0 +1,93 @@ +#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)); + } + } + } + + }; +} \ No newline at end of file diff --git a/jia/ex1.ini b/jia/ex1.ini new file mode 100644 index 0000000..f90c649 --- /dev/null +++ b/jia/ex1.ini @@ -0,0 +1,42 @@ +[Len] +sum=8 + +[Test1] +number1=1 +number2=2 +output=3 + +[Test2] +number1=-1 +number2=2 +output=1 + +[Test3] +number1=1 +number2=-5 +output=-4 + +[Test4] +number1=-1 +number2=-2 +output=-3 + +[Test5] +number1=1000 +number2=20000 +output=21000 + +[Test6] +number1=-1000 +number2=200 +output=-800 + +[Test7] +number1=3000 +number2=-10 +output=2990 + +[Test8] +number1=100000 +number2=5000000 +output=5100000 \ No newline at end of file diff --git a/jia/ex2.ini b/jia/ex2.ini new file mode 100644 index 0000000..aae3649 --- /dev/null +++ b/jia/ex2.ini @@ -0,0 +1,42 @@ +[Len] +sum=8 + +[Test1] +number1=1 +number2=2 +output=-1 + +[Test2] +number1=-1 +number2=2 +output=-3 + +[Test3] +number1=1 +number2=-5 +output=6 + +[Test4] +number1=-9 +number2=-11 +output=2 + +[Test5] +number1=10000 +number2=2000 +output=8000 + +[Test6] +number1=-1 +number2=200 +output=-201 + +[Test7] +number1=300 +number2=-10000 +output=10300 + +[Test8] +number1=10000 +number2=500000 +output=-490000 \ No newline at end of file diff --git a/jia/ex3.ini b/jia/ex3.ini new file mode 100644 index 0000000..831ee55 --- /dev/null +++ b/jia/ex3.ini @@ -0,0 +1,42 @@ +[Len] +sum=8 + +[Test1] +number1=1 +number2=2 +output=2 + +[Test2] +number1=-1 +number2=2 +output=-2 + +[Test3] +number1=1 +number2=-5 +output=-5 + +[Test4] +number1=-9 +number2=-11 +output=99 + +[Test5] +number1=100 +number2=200 +output=20000 + +[Test6] +number1=-10000 +number2=200 +output=-2000000 + +[Test7] +number1=300 +number2=-1 +output=-300 + +[Test8] +number1=-11 +number2=-11 +output=121 \ No newline at end of file diff --git a/jia/ex4.ini b/jia/ex4.ini new file mode 100644 index 0000000..4ae1105 --- /dev/null +++ b/jia/ex4.ini @@ -0,0 +1,42 @@ +[Len] +sum=8 + +[Test1] +number1=100 +number2=0 +output=0 + +[Test2] +number1=-2 +number2=1 +output=-2 + +[Test3] +number1=5 +number2=-1 +output=-5 + +[Test4] +number1=-10 +number2=-2 +output=5 + +[Test5] +number1=998 +number2=-998 +output=-1 + +[Test6] +number1=-10000 +number2=200 +output=-500 + +[Test7] +number1=300 +number2=-1 +output=-300 + +[Test8] +number1=0 +number2=1000 +output=0 \ No newline at end of file