diff --git a/NSun-S/.gitignore b/NSun-S/.gitignore new file mode 100644 index 00000000..6b721575 --- /dev/null +++ b/NSun-S/.gitignore @@ -0,0 +1,34 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +*.vs \ No newline at end of file diff --git a/NSun-S/Project1/Debug/Project1.ilk b/NSun-S/Project1/Debug/Project1.ilk new file mode 100644 index 00000000..fdccdc50 Binary files /dev/null and b/NSun-S/Project1/Debug/Project1.ilk differ diff --git a/NSun-S/Project1/Debug/Project1.pdb b/NSun-S/Project1/Debug/Project1.pdb new file mode 100644 index 00000000..f36ea5a3 Binary files /dev/null and b/NSun-S/Project1/Debug/Project1.pdb differ diff --git a/NSun-S/Project1/Debug/UnitTest1.exp b/NSun-S/Project1/Debug/UnitTest1.exp new file mode 100644 index 00000000..c6dc6984 Binary files /dev/null and b/NSun-S/Project1/Debug/UnitTest1.exp differ diff --git a/NSun-S/Project1/Debug/UnitTest1.ilk b/NSun-S/Project1/Debug/UnitTest1.ilk new file mode 100644 index 00000000..4dd37417 Binary files /dev/null and b/NSun-S/Project1/Debug/UnitTest1.ilk differ diff --git a/NSun-S/Project1/Debug/UnitTest1.pdb b/NSun-S/Project1/Debug/UnitTest1.pdb new file mode 100644 index 00000000..d2daeb22 Binary files /dev/null and b/NSun-S/Project1/Debug/UnitTest1.pdb differ diff --git a/NSun-S/Project1/Project1.sln b/NSun-S/Project1/Project1.sln new file mode 100644 index 00000000..f1f5b8f1 --- /dev/null +++ b/NSun-S/Project1/Project1.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29326.143 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{1F525612-0B6E-45C1-BCE5-06A9346E26CA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest1", "UnitTest1\UnitTest1.vcxproj", "{4BA9AF09-E866-4BBF-85A1-803BA0067796}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Debug|x64.ActiveCfg = Debug|x64 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Debug|x64.Build.0 = Debug|x64 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Debug|x86.ActiveCfg = Debug|Win32 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Debug|x86.Build.0 = Debug|Win32 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Release|x64.ActiveCfg = Release|x64 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Release|x64.Build.0 = Release|x64 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Release|x86.ActiveCfg = Release|Win32 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA}.Release|x86.Build.0 = Release|Win32 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Debug|x64.ActiveCfg = Debug|x64 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Debug|x64.Build.0 = Debug|x64 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Debug|x86.ActiveCfg = Debug|Win32 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Debug|x86.Build.0 = Debug|Win32 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Release|x64.ActiveCfg = Release|x64 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Release|x64.Build.0 = Release|x64 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Release|x86.ActiveCfg = Release|Win32 + {4BA9AF09-E866-4BBF-85A1-803BA0067796}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BD6CF3B2-2C8B-4EF1-8A88-BB781BC881C8} + EndGlobalSection +EndGlobal diff --git a/NSun-S/Project1/Project1/Calculator.cpp b/NSun-S/Project1/Project1/Calculator.cpp new file mode 100644 index 00000000..9b095783 --- /dev/null +++ b/NSun-S/Project1/Project1/Calculator.cpp @@ -0,0 +1,183 @@ + + +#include "stdafx.h" +#include +#include +#include +#include +#include +#include "stdlib.h" +#include +#include +#include "Calculator.h" + +#define random(a,b) (rand()%(b-a+1)+a) + +using namespace std; + +Calculator::Calculator() {} + +string Calculator::MakeFormula() +{ + string formula = ""; + + int count = random(2, 3); + int start = 0; + int number1 = random(1, 100); + + formula += to_string(number1); + while (start < count) + { + int operation = random(0, 3); + int number2 = random(1, 100); + if (operation == 3) + { + while (!(number1 % number2 == 0)) + { + number2 = random(1, number1); + } + number1 = number1 / number2; + } + else + { + number1 = number2; + } + formula += op[operation] + to_string(number2); + start++; + } + return formula; +}; + +string Calculator::Solve(string formula) +{ + vector* tempStack = new vector(); + stack* operatorStack = new stack(); + int len = formula.length(); + //cout << formula.substr(2, 3) << endl; + int k = 0; + for (int j = -1; j < len - 1; j++) + { + char formulaChar = formula[j + 1]; + if (j == len - 2 || formulaChar == '+' || formulaChar == '-' || + formulaChar == '*' || formulaChar == '/') + { + if (j == len - 2) + { + tempStack->push_back(formula.substr(k)); + } + else + { + if (k < j + 1)////////////////////////////// + { + tempStack->push_back(formula.substr(k, j + 1 - k)); + //cout << formula.substr(k, j + 1) << k << j+1<< endl; + } + if (operatorStack->empty()) + { + operatorStack->push(formulaChar); + } + else + { + char stackChar = operatorStack->top(); + if ((stackChar == '+' || stackChar == '-') + && (formulaChar == '*' || formulaChar == '/')) + { + operatorStack->push(formulaChar); + } + else + { + //tempStack->push_back(to_string(operatorStack->top())); + if ((formulaChar == '+' || formulaChar == '-')) + { + while (!operatorStack->empty()) + { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + + } + } + else + { + while (!operatorStack->empty()&&!(operatorStack->top()=='+'|| operatorStack->top() == '-')) + { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + + } + } + operatorStack->push(formulaChar); + } + } + } + k = j + 2; + } + } + while (!operatorStack->empty()) + { + tempStack->push_back(string(1, operatorStack->top())); + operatorStack->pop(); + } + stack* calcStack = new stack(); + for (int i = 0; i < tempStack->size(); i++) + { + string peekChar = tempStack->at(i); + if (peekChar != "+" && peekChar != "-" + && peekChar != "/" && peekChar != "*") + { + calcStack->push(peekChar); + } + else + { + int a1 = 0; + int b1 = 0; + if (!calcStack->empty()) + { + b1 = stoi(calcStack->top()); + calcStack->pop(); + } + if (!calcStack->empty()) + { + a1 = stoi(calcStack->top()); + calcStack->pop(); + } + if (peekChar == "+") + { + calcStack->push(to_string(a1 + b1)); + } + else if (peekChar == "-") + { + calcStack->push(to_string(a1 - b1)); + } + else if (peekChar == "*") + { + calcStack->push(to_string(a1 * b1)); + } + else if (peekChar == "/") + { + calcStack->push(to_string(a1 / b1)); + } + } + } + return formula + "=" + calcStack->top(); +} + +int main(int argc, char* argv[]) +{ + int n; + n = stoi(argv[1]); + //cin >> n; + std::fstream output("subject.txt", ios::out); + Calculator* calc = new Calculator(); + srand((unsigned int)time(NULL)); + for(int i = 0; i < n; i++){ + string question = calc->MakeFormula(); + //cout << question << endl; + string ret = calc->Solve(question); + output << ret << endl; + //cout << ret << endl; + //getchar(); + } + output.close(); +} + + diff --git a/NSun-S/Project1/Project1/Calculator.h b/NSun-S/Project1/Project1/Calculator.h new file mode 100644 index 00000000..43792f27 --- /dev/null +++ b/NSun-S/Project1/Project1/Calculator.h @@ -0,0 +1,19 @@ +#pragma once +#include "stdafx.h" +#include +#include +#include +#include "stdlib.h" +#include +#include +using namespace std; + +class Calculator +{ +private: + string op[4] = { "+", "-", "*", "/" }; +public: + Calculator(); + string MakeFormula(); + string Solve(string formula); +}; diff --git a/NSun-S/Project1/Project1/Debug/Project1.Build.CppClean.log b/NSun-S/Project1/Project1/Debug/Project1.Build.CppClean.log new file mode 100644 index 00000000..60d9bd19 --- /dev/null +++ b/NSun-S/Project1/Project1/Debug/Project1.Build.CppClean.log @@ -0,0 +1,3 @@ +d:\study\软件工程\lab0\calculator\nsun-s\project1\project1\debug\vc142.idb +d:\study\软件工程\lab0\calculator\nsun-s\project1\project1\debug\vc142.pdb +d:\study\软件工程\lab0\calculator\nsun-s\project1\project1\debug\project1.tlog\cl.command.1.tlog diff --git a/NSun-S/Project1/Project1/Debug/Project1.log b/NSun-S/Project1/Project1/Debug/Project1.log new file mode 100644 index 00000000..93455cb5 --- /dev/null +++ b/NSun-S/Project1/Project1/Debug/Project1.log @@ -0,0 +1,3 @@ + Calculator.cpp +D:\study\软件工程\lab0\Calculator\NSun-S\Project1\Project1\Calculator.cpp(121,20): warning C4018: “<”: 有符号/无符号不匹配 + Project1.vcxproj -> D:\study\软件工程\lab0\Calculator\NSun-S\Project1\Debug\Project1.exe diff --git a/NSun-S/Project1/Project1/Debug/Project1.stdafx b/NSun-S/Project1/Project1/Debug/Project1.stdafx new file mode 100644 index 00000000..969accef Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.stdafx differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.command.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.command.1.tlog new file mode 100644 index 00000000..ab673080 Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.command.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.read.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.read.1.tlog new file mode 100644 index 00000000..84c5b11d Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.read.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.write.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.write.1.tlog new file mode 100644 index 00000000..ba8f9e11 Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/CL.write.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/Project1.lastbuildstate b/NSun-S/Project1/Project1/Debug/Project1.tlog/Project1.lastbuildstate new file mode 100644 index 00000000..d64c3a72 --- /dev/null +++ b/NSun-S/Project1/Project1/Debug/Project1.tlog/Project1.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0 +Debug|Win32|D:\study\软件工程\lab0\Calculator\NSun-S\Project1\| diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/link.command.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.command.1.tlog new file mode 100644 index 00000000..4788f847 Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.command.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/link.read.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.read.1.tlog new file mode 100644 index 00000000..f9811f9f Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.read.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.tlog/link.write.1.tlog b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.write.1.tlog new file mode 100644 index 00000000..37bff7e6 Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/Project1.tlog/link.write.1.tlog differ diff --git a/NSun-S/Project1/Project1/Debug/Project1.vcxproj.FileListAbsolute.txt b/NSun-S/Project1/Project1/Debug/Project1.vcxproj.FileListAbsolute.txt new file mode 100644 index 00000000..e69de29b diff --git a/NSun-S/Project1/Project1/Debug/vc142.idb b/NSun-S/Project1/Project1/Debug/vc142.idb new file mode 100644 index 00000000..0c4d3eb6 Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/vc142.idb differ diff --git a/NSun-S/Project1/Project1/Debug/vc142.pdb b/NSun-S/Project1/Project1/Debug/vc142.pdb new file mode 100644 index 00000000..f853ecdf Binary files /dev/null and b/NSun-S/Project1/Project1/Debug/vc142.pdb differ diff --git a/NSun-S/Project1/Project1/Project1.vcxproj b/NSun-S/Project1/Project1/Project1.vcxproj new file mode 100644 index 00000000..b064a78a --- /dev/null +++ b/NSun-S/Project1/Project1/Project1.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {1F525612-0B6E-45C1-BCE5-06A9346E26CA} + Win32Proj + Project1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdafx.h + $(IntDir)$(TargetName).stdafx + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Create + Create + Create + Create + + + + + + + + + + + \ No newline at end of file diff --git a/NSun-S/Project1/Project1/Project1.vcxproj.filters b/NSun-S/Project1/Project1/Project1.vcxproj.filters new file mode 100644 index 00000000..63496587 --- /dev/null +++ b/NSun-S/Project1/Project1/Project1.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;ipp;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/NSun-S/Project1/Project1/Project1.vcxproj.user b/NSun-S/Project1/Project1/Project1.vcxproj.user new file mode 100644 index 00000000..009eed3e --- /dev/null +++ b/NSun-S/Project1/Project1/Project1.vcxproj.user @@ -0,0 +1,7 @@ + + + + 10 + WindowsLocalDebugger + + \ No newline at end of file diff --git a/NSun-S/Project1/Project1/stdafx.cpp b/NSun-S/Project1/Project1/stdafx.cpp new file mode 100644 index 00000000..2f94eeea --- /dev/null +++ b/NSun-S/Project1/Project1/stdafx.cpp @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "stdafx.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 \ No newline at end of file diff --git a/NSun-S/Project1/Project1/stdafx.h b/NSun-S/Project1/Project1/stdafx.h new file mode 100644 index 00000000..50de236b --- /dev/null +++ b/NSun-S/Project1/Project1/stdafx.h @@ -0,0 +1,12 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef STDAFX_H +#define STDAFX_H + +// 添加要在此处预编译的标头 + +#endif //PCH_H diff --git a/NSun-S/Project1/Project1/subject.txt b/NSun-S/Project1/Project1/subject.txt new file mode 100644 index 00000000..4eb2d234 --- /dev/null +++ b/NSun-S/Project1/Project1/subject.txt @@ -0,0 +1,10 @@ +71/71+73*28=2045 +100-87/1=13 +46*84*7=27048 +80*86*27=185760 +47+3-99*25=-2425 +73+37*8/1=369 +15+70+97-20=162 +72+94/2+26=145 +26+96/3=58 +63*19/1=1197 diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.log b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.log new file mode 100644 index 00000000..e7ca09c7 --- /dev/null +++ b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.log @@ -0,0 +1 @@ + UnitTest1.vcxproj -> D:\study\软件工程\lab0\Calculator\NSun-S\Project1\Debug\UnitTest1.dll diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.command.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.command.1.tlog new file mode 100644 index 00000000..520ab06f Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.command.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.read.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.read.1.tlog new file mode 100644 index 00000000..22746f90 Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.read.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.write.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.write.1.tlog new file mode 100644 index 00000000..6f2be5d7 Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/CL.write.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.lastbuildstate b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.lastbuildstate new file mode 100644 index 00000000..d64c3a72 --- /dev/null +++ b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0 +Debug|Win32|D:\study\软件工程\lab0\Calculator\NSun-S\Project1\| diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.write.1u.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.write.1u.tlog new file mode 100644 index 00000000..0e108e28 Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/UnitTest1.write.1u.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.command.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.command.1.tlog new file mode 100644 index 00000000..0faef9ce Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.command.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.read.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.read.1.tlog new file mode 100644 index 00000000..64afb63b Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.read.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.write.1.tlog b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.write.1.tlog new file mode 100644 index 00000000..763cae7c Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/UnitTest1.tlog/link.write.1.tlog differ diff --git a/NSun-S/Project1/UnitTest1/Debug/vc142.idb b/NSun-S/Project1/UnitTest1/Debug/vc142.idb new file mode 100644 index 00000000..3d24a10e Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/vc142.idb differ diff --git a/NSun-S/Project1/UnitTest1/Debug/vc142.pdb b/NSun-S/Project1/UnitTest1/Debug/vc142.pdb new file mode 100644 index 00000000..bad274d2 Binary files /dev/null and b/NSun-S/Project1/UnitTest1/Debug/vc142.pdb differ diff --git a/NSun-S/Project1/UnitTest1/UnitTest1.cpp b/NSun-S/Project1/UnitTest1/UnitTest1.cpp new file mode 100644 index 00000000..3dfa045f --- /dev/null +++ b/NSun-S/Project1/UnitTest1/UnitTest1.cpp @@ -0,0 +1,25 @@ +#include "pch.h" +#include "CppUnitTest.h" +#include "../Project1/calculator.h" +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace UnitTest1 +{ + TEST_CLASS(UnitTest1) + { + public: + + TEST_METHOD(TestMethod1) + { + Calculator* calc = new Calculator(); + string ret1 = calc->Solve("3+11*22"); + Assert::AreEqual(ret1, (string)"3+11*22=245"); + string ret2 = calc->Solve("3-5+2+3"); + Assert::AreEqual(ret2, (string)"3-5+2+3=3"); + string ret3 = calc->Solve("3-4*2+6"); + Assert::AreEqual(ret3, (string)"3-4*2+6=1"); + //string ret = calc->Solve("3+11*22"); + //Assert::AreEqual(ret, (string)"11*22=245"); + } + }; +} diff --git a/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj new file mode 100644 index 00000000..b53536e3 --- /dev/null +++ b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {4BA9AF09-E866-4BBF-85A1-803BA0067796} + Win32Proj + UnitTest1 + 10.0 + NativeUnitTestProject + + + + DynamicLibrary + true + v142 + Unicode + false + + + DynamicLibrary + false + v142 + true + Unicode + false + + + DynamicLibrary + true + v142 + Unicode + false + + + DynamicLibrary + false + v142 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + pch.h + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + ..\Project1\Debug\Calculator.obj;..\Project1\Debug\stdafx.obj;%(AdditionalDependencies) + + + + + Use + Level3 + Disabled + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + true + pch.h + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Use + Level3 + MaxSpeed + true + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + pch.h + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Use + Level3 + MaxSpeed + true + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + true + pch.h + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Create + Create + Create + Create + + + + + + + + + {1f525612-0b6e-45c1-bce5-06a9346e26ca} + + + + + + \ No newline at end of file diff --git a/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.filters b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.filters new file mode 100644 index 00000000..6c4e107f --- /dev/null +++ b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {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;ipp;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/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.user b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/NSun-S/Project1/UnitTest1/UnitTest1.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/NSun-S/Project1/UnitTest1/pch.cpp b/NSun-S/Project1/UnitTest1/pch.cpp new file mode 100644 index 00000000..b6fb8f4a --- /dev/null +++ b/NSun-S/Project1/UnitTest1/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git a/NSun-S/Project1/UnitTest1/pch.h b/NSun-S/Project1/UnitTest1/pch.h new file mode 100644 index 00000000..69fcd405 --- /dev/null +++ b/NSun-S/Project1/UnitTest1/pch.h @@ -0,0 +1,12 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 + +#endif //PCH_H