这是林永吉的算法题仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 regels
2.1 KiB

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