林永吉的Algorithm库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.7 KiB

  1. #include "pch.h"
  2. #include "CppUnitTest.h"
  3. using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  4. #define FileName_1 "../Alogrithm/config/1_ContainsNearbyDuplicate.ini"
  5. #define FileName_2 "../Alogrithm/config/2_ExcelSheetColumnTiTle.ini"
  6. #define FileName_3 "../Alogrithm/config/3_bool IsUgly.ini"
  7. #define FileName_4 "../Alogrithm/config/4_IsPalindrome.ini"
  8. namespace UnitTest
  9. {
  10. TEST_CLASS(UnitTest_1)
  11. {
  12. TEST_METHOD(TestMethode1)
  13. {
  14. char Section_Name[100][10] = { 0 };
  15. int Section_Count = CalcCount(100, Section_Name, FileName_1);
  16. int array_count = 0;
  17. int* Section_Value;
  18. CString Na, Nb, nExpect;
  19. for (int i = 0; i < Section_Count; i++) {
  20. GetPrivateProfileString(Section_Name[i], "array", " ", Na.GetBuffer(200), 200, FileName_1);
  21. GetPrivateProfileString(Section_Name[i], "key", " ", Nb.GetBuffer(20), 20, FileName_1);
  22. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_1);
  23. Section_Value = str_device(Na, &array_count);
  24. bool nReal = ContainsNearbyDuplicate(Section_Value, array_count, _ttoi(Nb));
  25. Assert::AreEqual(nReal, CstrToBool(nExpect));
  26. }
  27. }
  28. };
  29. TEST_CLASS(UnitTest_2)
  30. {
  31. TEST_METHOD(TestMethode1)
  32. {
  33. char Section_Name[100][10] = { 0 };
  34. int Section_Count = CalcCount(100, Section_Name, FileName_2);
  35. CString Na, nExpect;
  36. for (int i = 0; i < Section_Count; i++) {
  37. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_2);
  38. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(100), 100, FileName_2);
  39. char* nReal = ExcelSheetColumnTitle(_ttoi(Na));
  40. Assert::AreEqual(*nReal, *nExpect);
  41. }
  42. }
  43. };
  44. TEST_CLASS(UnitTest_3)
  45. {
  46. TEST_METHOD(TestMethode3)
  47. {
  48. char Section_Name[100][10] = { 0 };
  49. int Section_Count = CalcCount(100, Section_Name, FileName_3);
  50. CString Na, nExpect;
  51. for (int i = 0; i < Section_Count; i++) {
  52. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_3);
  53. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_3);
  54. bool nReal = IsUgly(_ttoi(Na));
  55. Assert::AreEqual(nReal, CstrToBool(nExpect));
  56. }
  57. }
  58. };
  59. TEST_CLASS(UnitTest_4)
  60. {
  61. TEST_METHOD(TestMethode1)
  62. {
  63. char Section_Name[100][10] = { 0 };
  64. int Section_Count = CalcCount(100, Section_Name, FileName_4);
  65. CString Na, nExpect;
  66. for (int i = 0; i < Section_Count; i++) {
  67. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_4);
  68. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_4);
  69. bool nReal = IsPalindrome(_ttoi(Na));
  70. Assert::AreEqual(nReal, CstrToBool(nExpect));
  71. }
  72. }
  73. };
  74. }