林永吉的Algorithm库
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.

61 regels
2.1 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. namespace UnitTest
  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. TEST_CLASS(UnitTest_2)
  29. {
  30. TEST_METHOD(TestMethode1)
  31. {
  32. char Section_Name[100][10] = { 0 };
  33. int Section_Count = CalcCount(100, Section_Name, FileName_2);
  34. CString Na, nExpect;
  35. for (int i = 0; i < Section_Count; i++) {
  36. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_2);
  37. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(100), 100, FileName_2);
  38. char* nReal = ExcelSheetColumnTitle(_ttoi(Na));
  39. Assert::AreEqual(*nReal, *nExpect);
  40. }
  41. }
  42. };
  43. TEST_CLASS(UnitTest_3)
  44. {
  45. TEST_METHOD(TestMethode3)
  46. {
  47. char Section_Name[100][10] = { 0 };
  48. int Section_Count = CalcCount(100, Section_Name, FileName_3);
  49. CString Na, nExpect;
  50. for (int i = 0; i < Section_Count; i++) {
  51. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_3);
  52. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_3);
  53. bool nReal = IsUgly(_ttoi(Na));
  54. Assert::AreEqual(nReal, CstrToBool(nExpect));
  55. }
  56. }
  57. };
  58. }