|
- #include "pch.h"
- #include "CppUnitTest.h"
-
- using namespace Microsoft::VisualStudio::CppUnitTestFramework;
- #define FileName_1 "../code/config/1_ContainsNearbyDuplicate.ini"
- #define FileName_2 "../code/config/2_ExcelSheetColumnTiTle.ini"
- #define FileName_3 "../code/config/3_IsUgly.ini"
- #define FileName_4 "../code/config/4_IsPalindrome.ini"
- #define FileName_5 "../code/config/5_MinDepth.ini"
-
-
- namespace test1
- {
- TEST_CLASS(UnitTest_1)
- {
- TEST_METHOD(TestMethode1)
- {
- char Section_Name[100][10] = { 0 };
- int Section_Count = CalcCount(100, Section_Name, FileName_1);
- int array_count = 0;
- int* Section_Value;
- CString Na, Nb, nExpect;
- for (int i = 0; i < Section_Count; i++) {
- GetPrivateProfileString(Section_Name[i], "array", " ", Na.GetBuffer(200), 200, FileName_1);
- GetPrivateProfileString(Section_Name[i], "key", " ", Nb.GetBuffer(20), 20, FileName_1);
- GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_1);
- Section_Value = str_device(Na, &array_count);
- bool nReal = ContainsNearbyDuplicate(Section_Value, array_count, _ttoi(Nb));
- Assert::AreEqual(nReal, CstrToBool(nExpect));
- }
- }
- };
- }
- namespace test2
- {
- TEST_CLASS(UnitTest_1)
- {
- TEST_METHOD(TestMethode1)
- {
- char Section_Name[100][10] = { 0 };
- int Section_Count = CalcCount(100, Section_Name, FileName_2);
- CString Na, nExpect;
- for (int i = 0; i < Section_Count; i++) {
- GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_2);
- GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(100), 100, FileName_2);
- char* nReal = ExcelSheetColumnTitle(_ttoi(Na));
- Assert::AreEqual(nReal, nExpect);
- }
- }
- };
- }
- namespace test3
- {
- TEST_CLASS(UnitTest_1)
- {
- TEST_METHOD(TestMethode1)
- {
- char Section_Name[100][10] = { 0 };
- int Section_Count = CalcCount(100, Section_Name, FileName_3);
- CString Na, nExpect;
- for (int i = 0; i < Section_Count; i++) {
- GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_3);
- GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_3);
- bool nReal = IsUgly(_ttoi(Na));
- Assert::AreEqual(nReal, CstrToBool(nExpect));
- }
- }
- };
- }
- namespace test4
- {
- TEST_CLASS(UnitTest_4)
- {
- TEST_METHOD(TestMethode1)
- {
- char Section_Name[100][10] = { 0 };
- int Section_Count = CalcCount(100, Section_Name, FileName_4);
- CString Na, nExpect;
- for (int i = 0; i < Section_Count; i++) {
- GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_4);
- GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_4);
- bool nReal = IsPalindrome(_ttoi(Na));
- Assert::AreEqual(nReal, CstrToBool(nExpect));
- }
- }
- };
- }
- namespace test5
- {
- TEST_CLASS(UnitTest_5)
- {
- TEST_METHOD(TestMethode1)
- {
- char Section_Name[100][10] = { 0 };
- int Section_Count = CalcCount(100, Section_Name, FileName_5);
- CString Na, nExpect;
- for (int i = 0; i < Section_Count; i++) {
- GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_5);
- GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_5);
- char return_str[100][50] = { 0 };
- int return_count = str_device2(Na, return_str);
- TreeNode* root = CreatBitTree(return_str, return_count);
- int nReal = MinDepth(root);
- Assert::AreEqual(nReal, _ttoi(nExpect));
- free_tree(root);
- }
- }
- };
- }
|