Autor | SHA1 | Zpráva | Datum |
---|---|---|---|
|
21d0101f28 | 11 | před 4 roky |
|
c55e356b67 | 11 | před 4 roky |
|
d8670bc4da | 11 | před 4 roky |
|
65ffeeb131 | 55 | před 4 roky |
|
3e3f2a754b | Merge branch 'test3' | před 4 roky |
|
dd002ddccf | Merge branch 'test2' | před 4 roky |
|
a0ef46658c | 44 | před 4 roky |
|
405c604b4b | 33 | před 4 roky |
@@ -0,0 +1,99 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|Win32"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|Win32"> | |||
<Configuration>Release</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>{624E0933-6EC9-4441-B0E7-B91AD913A772}</ProjectGuid> | |||
<Keyword>Win32Proj</Keyword> | |||
<RootNamespace>UnitTest1</RootNamespace> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||
<ConfigurationType>DynamicLibrary</ConfigurationType> | |||
<UseDebugLibraries>true</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<CharacterSet>MultiByte</CharacterSet> | |||
<UseOfMfc>false</UseOfMfc> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||
<ConfigurationType>DynamicLibrary</ConfigurationType> | |||
<UseDebugLibraries>false</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||
<CharacterSet>Unicode</CharacterSet> | |||
<UseOfMfc>false</UseOfMfc> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||
<ImportGroup Label="ExtensionSettings"> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<PropertyGroup Label="UserMacros" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<LinkIncremental>true</LinkIncremental> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<LinkIncremental>true</LinkIncremental> | |||
</PropertyGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<ClCompile> | |||
<PrecompiledHeader>Use</PrecompiledHeader> | |||
<WarningLevel>Level3</WarningLevel> | |||
<Optimization>Disabled</Optimization> | |||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
<UseFullPaths>true</UseFullPaths> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Windows</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | |||
<AdditionalDependencies>..\jia\Debug\jia.obj;..\jian\Debug\jian.obj;..\chen\Debug\chen.obj;..\chu\Debug\chu.obj;..\chu\Debug\tof.obj;%(AdditionalDependencies)</AdditionalDependencies> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<ClCompile> | |||
<WarningLevel>Level3</WarningLevel> | |||
<PrecompiledHeader>Use</PrecompiledHeader> | |||
<Optimization>MaxSpeed</Optimization> | |||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
<UseFullPaths>true</UseFullPaths> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Windows</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||
<OptimizeReferences>true</OptimizeReferences> | |||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemGroup> | |||
<ClInclude Include="stdafx.h" /> | |||
<ClInclude Include="targetver.h" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClCompile Include="stdafx.cpp"> | |||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | |||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | |||
</ClCompile> | |||
<ClCompile Include="unittest1.cpp" /> | |||
</ItemGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
<ImportGroup Label="ExtensionTargets"> | |||
</ImportGroup> | |||
</Project> |
@@ -0,0 +1,33 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup> | |||
<Filter Include="源文件"> | |||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | |||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | |||
</Filter> | |||
<Filter Include="头文件"> | |||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | |||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | |||
</Filter> | |||
<Filter Include="资源文件"> | |||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | |||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | |||
</Filter> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClInclude Include="stdafx.h"> | |||
<Filter>头文件</Filter> | |||
</ClInclude> | |||
<ClInclude Include="targetver.h"> | |||
<Filter>头文件</Filter> | |||
</ClInclude> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClCompile Include="stdafx.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
<ClCompile Include="unittest1.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,8 @@ | |||
// stdafx.cpp : 只包括标准包含文件的源文件 | |||
// UnitTest1.pch 将作为预编译头 | |||
// stdafx.obj 将包含预编译类型信息 | |||
#include "stdafx.h" | |||
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件, | |||
//而不是在此文件中引用 |
@@ -0,0 +1,13 @@ | |||
// stdafx.h : 标准系统包含文件的包含文件, | |||
// 或是经常使用但不常更改的 | |||
// 特定于项目的包含文件 | |||
// | |||
#pragma once | |||
#include "targetver.h" | |||
// 用于 CppUnitTest 的头文件 | |||
#include "CppUnitTest.h" | |||
// TODO: 在此处引用程序需要的其他头文件 |
@@ -0,0 +1,8 @@ | |||
#pragma once | |||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 | |||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将 | |||
// _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 | |||
#include <SDKDDKVer.h> |
@@ -0,0 +1,133 @@ | |||
#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" | |||
#include"../chu/tof.h" | |||
#include <limits> | |||
//#include "iostream" | |||
//using namespace std; | |||
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[10]; | |||
char TestStr[10] = { "Test" }; | |||
_itoa_s(i, SUMStr, 10); | |||
strcat_s(TestStr, SUMStr); | |||
//string str(TestStr); | |||
int num1 = GetPrivateProfileInt(TestStr, "number1", 0, "..//ex1.ini"); | |||
int num2 = GetPrivateProfileInt(TestStr, "number2", 0, "..//ex1.ini"); | |||
int c = 0; | |||
bool ret1 = Add(num1, num2, &c); | |||
if (ret1 == 1) | |||
{ | |||
int output = GetPrivateProfileInt(TestStr, "output", 0, "..//ex1.ini"); | |||
Assert::AreEqual(output, c); | |||
} | |||
else | |||
{ | |||
LPTSTR Output = (LPTSTR)malloc(255); | |||
GetPrivateProfileString(TestStr, "output", "", Output, 255, "..//ex1.ini"); | |||
string s(Output); | |||
Assert::AreEqual(tof(s), Add(num1, num2, &c)); | |||
} | |||
} | |||
} | |||
} | |||
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 d = 0; | |||
bool ret2 = Sub(num1, num2, &d); | |||
if (ret2 == 1) | |||
{ | |||
int output = GetPrivateProfileInt(TestStr, "output", 0, "..//ex2.ini"); | |||
Assert::AreEqual(output, d); | |||
} | |||
else | |||
{ | |||
LPTSTR Output = (LPTSTR)malloc(255); | |||
GetPrivateProfileString(TestStr, "output", "", Output, 255, "..//ex2.ini"); | |||
string s(Output); | |||
Assert::AreEqual(tof(s), Sub(num1, num2, &d)); | |||
} | |||
} | |||
} | |||
} | |||
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 e = 0; | |||
bool ret3 = chen(num1, num2, &e); | |||
if (ret3 == 1) | |||
{ | |||
int output = GetPrivateProfileInt(TestStr, "output", 0, "..//ex3.ini"); | |||
Assert::AreEqual(output, e); | |||
} | |||
else | |||
{ | |||
LPTSTR Output = (LPTSTR)malloc(255); | |||
GetPrivateProfileString(TestStr, "output", "", Output, 255, "..//ex3.ini"); | |||
string s(Output); | |||
Assert::AreEqual(tof(s), chen(num1, num2, &e)); | |||
} | |||
} | |||
} | |||
} | |||
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)); | |||
} | |||
} | |||
} | |||
}; | |||
} |
@@ -0,0 +1,3 @@ | |||
LIBRARY chen | |||
EXPORTS | |||
chen |
@@ -0,0 +1,25 @@ | |||
#include "chen.h" | |||
#include <limits> | |||
bool chen(int a, int b, int *e) | |||
{ | |||
if ((a>0 && b>0 && a >(INT_MAX / b)) || (a<0 && b<0 && a < (INT_MAX / b))) | |||
{ | |||
return false; | |||
} | |||
else if ((a > 0 && b < 0 && b != -1 && (INT_MIN / a) > b || (a < 0 && b > 0 && a != -1 && (INT_MIN / a) < b))) | |||
{ | |||
return false; | |||
} | |||
else | |||
{ | |||
*e = a * b; | |||
return true; | |||
} | |||
} | |||
@@ -0,0 +1,7 @@ | |||
#ifndef CHEN_H | |||
#define CHEN_H | |||
bool chen(int a, int b, int *e); | |||
#endif |
@@ -0,0 +1,92 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|Win32"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|Win32"> | |||
<Configuration>Release</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>{D3E01979-7A19-4FCB-B43B-59E1F322215F}</ProjectGuid> | |||
<Keyword>Win32Proj</Keyword> | |||
<RootNamespace>chen</RootNamespace> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||
<ConfigurationType>DynamicLibrary</ConfigurationType> | |||
<UseDebugLibraries>true</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<CharacterSet>Unicode</CharacterSet> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||
<ConfigurationType>DynamicLibrary</ConfigurationType> | |||
<UseDebugLibraries>false</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||
<CharacterSet>Unicode</CharacterSet> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||
<ImportGroup Label="ExtensionSettings"> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<PropertyGroup Label="UserMacros" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<LinkIncremental>true</LinkIncremental> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<LinkIncremental>false</LinkIncremental> | |||
</PropertyGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<ClCompile> | |||
<PrecompiledHeader> | |||
</PrecompiledHeader> | |||
<WarningLevel>Level3</WarningLevel> | |||
<Optimization>Disabled</Optimization> | |||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CHEN_EXPORTS;_DLLAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Windows</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<ClCompile> | |||
<WarningLevel>Level3</WarningLevel> | |||
<PrecompiledHeader> | |||
</PrecompiledHeader> | |||
<Optimization>MaxSpeed</Optimization> | |||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHEN_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Windows</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||
<OptimizeReferences>true</OptimizeReferences> | |||
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemGroup> | |||
<ClInclude Include="chen.h" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClCompile Include="chen.cpp" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="Source.def" /> | |||
</ItemGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
<ImportGroup Label="ExtensionTargets"> | |||
</ImportGroup> | |||
</Project> |
@@ -0,0 +1,32 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup> | |||
<Filter Include="源文件"> | |||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | |||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | |||
</Filter> | |||
<Filter Include="头文件"> | |||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | |||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | |||
</Filter> | |||
<Filter Include="资源文件"> | |||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | |||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | |||
</Filter> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClInclude Include="chen.h"> | |||
<Filter>头文件</Filter> | |||
</ClInclude> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClCompile Include="chen.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="Source.def"> | |||
<Filter>源文件</Filter> | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,14 @@ | |||
#include "chu.h" | |||
int chu(int a, int b) | |||
{ | |||
if (b != 0) | |||
{ | |||
return a / b; | |||
} | |||
else | |||
{ | |||
return 0; | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
#ifndef DIV_H | |||
#define DIV_H | |||
int chu(int a, int b); | |||
#endif |
@@ -0,0 +1,93 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup Label="ProjectConfigurations"> | |||
<ProjectConfiguration Include="Debug|Win32"> | |||
<Configuration>Debug</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
<ProjectConfiguration Include="Release|Win32"> | |||
<Configuration>Release</Configuration> | |||
<Platform>Win32</Platform> | |||
</ProjectConfiguration> | |||
</ItemGroup> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>{1A262FA8-268E-4CDD-8411-9C91E928BB6C}</ProjectGuid> | |||
<Keyword>Win32Proj</Keyword> | |||
<RootNamespace>chu</RootNamespace> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||
<ConfigurationType>Application</ConfigurationType> | |||
<UseDebugLibraries>true</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<CharacterSet>MultiByte</CharacterSet> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||
<ConfigurationType>Application</ConfigurationType> | |||
<UseDebugLibraries>false</UseDebugLibraries> | |||
<PlatformToolset>v120</PlatformToolset> | |||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||
<CharacterSet>Unicode</CharacterSet> | |||
</PropertyGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||
<ImportGroup Label="ExtensionSettings"> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
</ImportGroup> | |||
<PropertyGroup Label="UserMacros" /> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<LinkIncremental>true</LinkIncremental> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<LinkIncremental>false</LinkIncremental> | |||
</PropertyGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||
<ClCompile> | |||
<PrecompiledHeader> | |||
</PrecompiledHeader> | |||
<WarningLevel>Level3</WarningLevel> | |||
<Optimization>Disabled</Optimization> | |||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_DLLAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Console</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<AdditionalLibraryDirectories>..\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | |||
<AdditionalDependencies>..\Debug\jia.lib;..\Debug\jian.lib;..\Debug\chen.lib;%(AdditionalDependencies)</AdditionalDependencies> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||
<ClCompile> | |||
<WarningLevel>Level3</WarningLevel> | |||
<PrecompiledHeader> | |||
</PrecompiledHeader> | |||
<Optimization>MaxSpeed</Optimization> | |||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Console</SubSystem> | |||
<GenerateDebugInformation>true</GenerateDebugInformation> | |||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||
<OptimizeReferences>true</OptimizeReferences> | |||
</Link> | |||
</ItemDefinitionGroup> | |||
<ItemGroup> | |||
<ClCompile Include="chu.cpp" /> | |||
<ClCompile Include="main.cpp" /> | |||
<ClCompile Include="tof.cpp" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClInclude Include="chu.h" /> | |||
<ClInclude Include="tof.h" /> | |||
</ItemGroup> | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
<ImportGroup Label="ExtensionTargets"> | |||
</ImportGroup> | |||
</Project> |
@@ -0,0 +1,36 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<ItemGroup> | |||
<Filter Include="源文件"> | |||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | |||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | |||
</Filter> | |||
<Filter Include="头文件"> | |||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | |||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | |||
</Filter> | |||
<Filter Include="资源文件"> | |||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | |||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | |||
</Filter> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClCompile Include="main.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
<ClCompile Include="chu.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
<ClCompile Include="tof.cpp"> | |||
<Filter>源文件</Filter> | |||
</ClCompile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ClInclude Include="chu.h"> | |||
<Filter>头文件</Filter> | |||
</ClInclude> | |||
<ClInclude Include="tof.h"> | |||
<Filter>头文件</Filter> | |||
</ClInclude> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup /> | |||
</Project> |
@@ -0,0 +1,107 @@ | |||
#include <stdio.h> | |||
#include "../jia/jia.h" | |||
//#pragma comment(lib,"jia.lib") | |||
#include "../jian/jian.h" | |||
//#pragma comment(lib,"jian.lib") | |||
#include "chu.h" | |||
#include "windows.h" | |||
#include "../chen/chen.h" | |||
#include <iostream> | |||
#include "tof.h" | |||
using namespace std; | |||
typedef bool(*QCHEN)(int a, int b,int *e); | |||
int main() | |||
{ | |||
int c = 0; | |||
int d = 0; | |||
int e = 0; | |||
__int64 a, b; | |||
/*scanf("%I64d", &a); | |||
scanf("%I64d", &b);*/ | |||
/*char f = 0; | |||
char *d = &f;*/ | |||
printf("请输入两个整数\n"); | |||
scanf("%I64d", &a); | |||
scanf("%I64d", &b); | |||
if (a > 2147483647) | |||
{ | |||
printf("输入错误!请重新输入!\n"); | |||
return 0; | |||
} | |||
else if (b > 2147483647) | |||
{ | |||
printf("输入错误!请重新输入!\n"); | |||
return 0; | |||
} | |||
else if (a < -2147483647) | |||
{ | |||
printf("输入错误!请重新输入!\n"); | |||
return 0; | |||
} | |||
else if (b < -2147483647) | |||
{ | |||
printf("输入错误!请重新输入!\n"); | |||
return 0; | |||
} | |||
else | |||
{ | |||
bool ret1 = Add(a, b, &c); | |||
if (ret1 == 0) | |||
{ | |||
printf("两个整数相加结果溢出!\n"); | |||
} | |||
else | |||
{ | |||
printf("两个整数的相加结果是;%d\n", c); | |||
} | |||
//printf("两个整数的相减结果是;%d\n,%d", Sub(a, b, d)); | |||
bool ret2 = Sub(a, b, &d); | |||
if (ret2 == 0) | |||
{ | |||
printf("两个整数相减结果溢出!\n "); | |||
} | |||
else | |||
{ | |||
printf("两个整数的相减结果是;%d\n", d); | |||
} | |||
HMODULE hDLL = LoadLibrary("../Debug/chen.dll"); | |||
if (hDLL == NULL) | |||
{ | |||
printf("加载DLL文件失败\n"); | |||
return 0; | |||
} | |||
// PMUL pMul = (PMUL)GetProcAddress(hDLL, "mul"); | |||
QCHEN qChen = (QCHEN)GetProcAddress(hDLL, "chen"); | |||
bool ret3 = chen(a, b, &e); | |||
if (ret3 == 0) | |||
{ | |||
printf("两个整数相乘结果溢出!\n "); | |||
} | |||
else | |||
{ | |||
printf("两个整数的相乘结果是;%d\n", e); | |||
} | |||
printf("两个整数的相除结果是;%d\n", chu(a, b)); | |||
system("pause"); | |||
FreeLibrary(hDLL); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
#include "tof.h" | |||
bool tof(string a) | |||
{ | |||
string b = "false"; | |||
if (a == b) | |||
{ | |||
return false; | |||
} | |||
else | |||
{ | |||
return true; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
#ifndef TOF_H | |||
#define TOF_H | |||
#include <iostream> | |||
using namespace std; | |||
bool tof(string a); | |||
#endif |
@@ -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=2000000000 | |||
number2=2000000000 | |||
output=false | |||
[Test6] | |||
number1=-1000 | |||
number2=200 | |||
output=-800 | |||
[Test7] | |||
number1=3000 | |||
number2=-10 | |||
output=2990 | |||
[Test8] | |||
number1=-1000000000 | |||
number2=-2000000000 | |||
output=false |
@@ -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=-1000000000 | |||
number2=2000000000 | |||
output=false | |||
[Test6] | |||
number1=-1 | |||
number2=200 | |||
output=-201 | |||
[Test7] | |||
number1=300 | |||
number2=-10000 | |||
output=10300 | |||
[Test8] | |||
number1=2000000000 | |||
number2=-2000000000 | |||
output=false |
@@ -0,0 +1,42 @@ | |||
[Len] | |||
sum=8 | |||
[Test1] | |||
number1=1 | |||
number2=2 | |||
output=2 | |||
[Test2] | |||
number1=-1 | |||
number2=2 | |||
output=-2 | |||
[Test3] | |||
number1=1000000 | |||
number2=50000 | |||
output=false | |||
[Test4] | |||
number1=-9000000 | |||
number2=-11000 | |||
output=false | |||
[Test5] | |||
number1=9 | |||
number2=9 | |||
output=81 | |||
[Test6] | |||
number1=-100000 | |||
number2=200000 | |||
output=false | |||
[Test7] | |||
number1=1000000 | |||
number2=-20000 | |||
output=false | |||
[Test8] | |||
number1=2 | |||
number2=2 | |||
output=4 |
@@ -0,0 +1,42 @@ | |||
[Len] | |||
sum=8 | |||
[Test1] | |||
number1=100 | |||
number2=1 | |||
output=100 | |||
[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=-50 | |||
[Test7] | |||
number1=300 | |||
number2=0 | |||
output=false | |||
[Test8] | |||
number1=0 | |||
number2=1000 | |||
output=0 |
@@ -0,0 +1,46 @@ | |||
| |||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||
# Visual Studio 2013 | |||
VisualStudioVersion = 12.0.40629.0 | |||
MinimumVisualStudioVersion = 10.0.40219.1 | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jia", "jia\jia.vcxproj", "{FC133E06-9EE0-4441-A557-12C5BFB381DB}" | |||
EndProject | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chu", "chu\chu.vcxproj", "{1A262FA8-268E-4CDD-8411-9C91E928BB6C}" | |||
EndProject | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chen", "chen\chen.vcxproj", "{D3E01979-7A19-4FCB-B43B-59E1F322215F}" | |||
EndProject | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jian", "jian\jian.vcxproj", "{D63C0C9A-957C-480B-91CA-63EEB17CC4D3}" | |||
EndProject | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest1", "UnitTest1\UnitTest1.vcxproj", "{624E0933-6EC9-4441-B0E7-B91AD913A772}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Win32 = Debug|Win32 | |||
Release|Win32 = Release|Win32 | |||
EndGlobalSection | |||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
{FC133E06-9EE0-4441-A557-12C5BFB381DB}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
{FC133E06-9EE0-4441-A557-12C5BFB381DB}.Debug|Win32.Build.0 = Debug|Win32 | |||
{FC133E06-9EE0-4441-A557-12C5BFB381DB}.Release|Win32.ActiveCfg = Release|Win32 | |||
{FC133E06-9EE0-4441-A557-12C5BFB381DB}.Release|Win32.Build.0 = Release|Win32 | |||
{1A262FA8-268E-4CDD-8411-9C91E928BB6C}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
{1A262FA8-268E-4CDD-8411-9C91E928BB6C}.Debug|Win32.Build.0 = Debug|Win32 | |||
{1A262FA8-268E-4CDD-8411-9C91E928BB6C}.Release|Win32.ActiveCfg = Release|Win32 | |||
{1A262FA8-268E-4CDD-8411-9C91E928BB6C}.Release|Win32.Build.0 = Release|Win32 | |||
{D3E01979-7A19-4FCB-B43B-59E1F322215F}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
{D3E01979-7A19-4FCB-B43B-59E1F322215F}.Debug|Win32.Build.0 = Debug|Win32 | |||
{D3E01979-7A19-4FCB-B43B-59E1F322215F}.Release|Win32.ActiveCfg = Release|Win32 | |||
{D3E01979-7A19-4FCB-B43B-59E1F322215F}.Release|Win32.Build.0 = Release|Win32 | |||
{D63C0C9A-957C-480B-91CA-63EEB17CC4D3}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
{D63C0C9A-957C-480B-91CA-63EEB17CC4D3}.Debug|Win32.Build.0 = Debug|Win32 | |||
{D63C0C9A-957C-480B-91CA-63EEB17CC4D3}.Release|Win32.ActiveCfg = Release|Win32 | |||
{D63C0C9A-957C-480B-91CA-63EEB17CC4D3}.Release|Win32.Build.0 = Release|Win32 | |||
{624E0933-6EC9-4441-B0E7-B91AD913A772}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
{624E0933-6EC9-4441-B0E7-B91AD913A772}.Debug|Win32.Build.0 = Debug|Win32 | |||
{624E0933-6EC9-4441-B0E7-B91AD913A772}.Release|Win32.ActiveCfg = Release|Win32 | |||
{624E0933-6EC9-4441-B0E7-B91AD913A772}.Release|Win32.Build.0 = Release|Win32 | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
EndGlobalSection | |||
EndGlobal |
@@ -1,23 +1,19 @@ | |||
#include "jia.h" | |||
#include <limits> | |||
bool Add(int a, int b, int *c) | |||
bool Add(int a, int b, int *c) | |||
{ | |||
if (a>0&&b>0&&a > INT_MAX - b ||a<0&&b<0&& a < INT_MIN - b) | |||
{ | |||
if ((a > 0 && b > 0 && a > (INT_MAX - b)) || (a < 0 && b < 0 && a < (INT_MIN - b))) | |||
{ | |||
return false; | |||
} | |||
else | |||
{ | |||
*c = a + b; | |||
return true; | |||
} | |||
} | |||
int add(int a, int b) | |||
{ | |||
return a + b; | |||
} | |||
@@ -1,6 +1,6 @@ | |||
#ifndef ADD_H | |||
#define ADD_H | |||
bool Add(int a, int b, int *c); | |||
int add(int a, int b); | |||
bool Add(int a, int b,int *c); | |||
//int add(int a,int b); | |||
#endif |
@@ -1,5 +1,23 @@ | |||
#include "jian.h" | |||
#include <limits> | |||
//char Sub(int a, int b, char *d) | |||
//{ | |||
// if ((a>0 && b<0 && a >(INT_MAX + b)) || (a<0 && b>0 && a < (INT_MIN + b))) | |||
// { | |||
// char *c = { "overflow" }; | |||
// *d = c[0]; | |||
// return d[0]; | |||
// } | |||
// else | |||
// { | |||
// d[0] = (a - b) + '0'; | |||
// return d[0]; | |||
// | |||
// } | |||
// | |||
//} | |||
bool Sub(int a, int b, int *d) | |||
{ | |||
if ((a>0 &&b<0 && a >( INT_MAX + b)) ||( a<0 && b>0 && a < (INT_MIN + b))) | |||
@@ -15,7 +33,7 @@ bool Sub(int a, int b, int *d) | |||
} | |||
} | |||
int sub(int a, int b) | |||
{ | |||
return a - b; | |||
} | |||
//int sub(int a, int b) | |||
//{ | |||
// return a - b; | |||
//} |
@@ -5,7 +5,7 @@ | |||
#else | |||
#define DLLAPI _declspec(dllimport) | |||
#endif | |||
int DLLAPI sub(int a, int b); | |||
//int DLLAPI sub(int a, int b); | |||
bool DLLAPI Sub(int a, int b, int *d); | |||
//char DLLAPI Sub(int a, int b, char *d); | |||
#endif |