这是林永吉的算法题仓库
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.

50 line
1.5 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. namespace test1
  7. {
  8. TEST_CLASS(UnitTest_1)
  9. {
  10. TEST_METHOD(TestMethode1)
  11. {
  12. char Section_Name[100][10] = { 0 };
  13. int Section_Count = CalcCount(100, Section_Name, FileName_1);
  14. int array_count = 0;
  15. int* Section_Value;
  16. CString Na, Nb, nExpect;
  17. for (int i = 0; i < Section_Count; i++) {
  18. GetPrivateProfileString(Section_Name[i], "array", " ", Na.GetBuffer(200), 200, FileName_1);
  19. GetPrivateProfileString(Section_Name[i], "key", " ", Nb.GetBuffer(20), 20, FileName_1);
  20. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_1);
  21. Section_Value = str_device(Na, &array_count);
  22. bool nReal = ContainsNearbyDuplicate(Section_Value, array_count, _ttoi(Nb));
  23. Assert::AreEqual(nReal, CstrToBool(nExpect));
  24. }
  25. }
  26. };
  27. }
  28. namespace test2
  29. {
  30. TEST_CLASS(UnitTest_1)
  31. {
  32. TEST_METHOD(TestMethode1)
  33. {
  34. char Section_Name[100][10] = { 0 };
  35. int Section_Count = CalcCount(100, Section_Name, FileName_2);
  36. CString Na, nExpect;
  37. for (int i = 0; i < Section_Count; i++) {
  38. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_2);
  39. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(100), 100, FileName_2);
  40. char* nReal = ExcelSheetColumnTitle(_ttoi(Na));
  41. Assert::AreEqual(nReal, nExpect);
  42. }
  43. }
  44. };
  45. }