林永吉的Algorithm库
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

512 行
19 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. #define FileName_5 "../Alogrithm/config/5_MinDepth.ini"
  9. #define FileName_6 "../Alogrithm/config/6_ContainsDuplicate.ini"
  10. #define FileName_7 "../Alogrithm/config/7_MaxDepth.ini"
  11. #define FileName_8 "../Alogrithm/config/8_HammingWeight.ini"
  12. #define FileName_9 "../Alogrithm/config/9_AddBinary.ini"
  13. #define FileName_10 "../Alogrithm/config/10_BinaryTreePaths.ini"
  14. #define FileName_11 "../Alogrithm/config/11_CanWinNim.ini"
  15. #define FileName_12 "../Alogrithm/config/12_IsValid.ini"
  16. #define FileName_13 "../Alogrithm/config/13_MyAtoi.ini"
  17. #define FileName_14 "../Alogrithm/config/14_SingleNumber.ini"
  18. #define FileName_15 "../Alogrithm/config/15_WordPattern.ini"
  19. #define FileName_16 "../Alogrithm/config/16_ReverseBits.ini"
  20. #define FileName_17 "../Alogrithm/config/17_WordBreak.ini"
  21. #define FileName_18 "../Alogrithm/config/18_PlusOne.ini"
  22. #define FileName_19 "../Alogrithm/config/19_MySqrt.ini"
  23. #define FileName_20 "../Alogrithm/config/20_MoveZeroes.ini"
  24. #define FileName_21 "../Alogrithm/config/21_Reverse.ini"
  25. #define FileName_22 "../Alogrithm/config/22_Rotate.ini"
  26. #define FileName_23 "../Alogrithm/config/23_RestoreIpAddresses.ini"
  27. #define FileName_24 "../Alogrithm/config/24_LengthOfLongestSubstring.ini"
  28. #define FileName_25 "../Alogrithm/config/25_Partition.ini"
  29. namespace UnitTest
  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_1);
  37. int array_count = 0;
  38. int* Section_Value;
  39. CString Na, Nb, nExpect;
  40. for (int i = 0; i < Section_Count; i++) {
  41. GetPrivateProfileString(Section_Name[i], "array", " ", Na.GetBuffer(200), 200, FileName_1);
  42. GetPrivateProfileString(Section_Name[i], "key", " ", Nb.GetBuffer(20), 20, FileName_1);
  43. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_1);
  44. Section_Value = str_device(Na, &array_count);
  45. bool nReal = ContainsNearbyDuplicate(Section_Value, array_count, _ttoi(Nb));
  46. Assert::AreEqual(nReal, CstrToBool(nExpect));
  47. }
  48. }
  49. };
  50. TEST_CLASS(UnitTest_2)
  51. {
  52. TEST_METHOD(TestMethode1)
  53. {
  54. char Section_Name[100][10] = { 0 };
  55. int Section_Count = CalcCount(100, Section_Name, FileName_2);
  56. CString Na, nExpect;
  57. for (int i = 0; i < Section_Count; i++) {
  58. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_2);
  59. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(100), 100, FileName_2);
  60. char* nReal = ExcelSheetColumnTitle(_ttoi(Na));
  61. Assert::AreEqual(nReal, nExpect);
  62. }
  63. }
  64. };
  65. TEST_CLASS(UnitTest_3)
  66. {
  67. TEST_METHOD(TestMethode3)
  68. {
  69. char Section_Name[100][10] = { 0 };
  70. int Section_Count = CalcCount(100, Section_Name, FileName_3);
  71. CString Na, nExpect;
  72. for (int i = 0; i < Section_Count; i++) {
  73. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_3);
  74. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_3);
  75. bool nReal = IsUgly(_ttoi(Na));
  76. Assert::AreEqual(nReal, CstrToBool(nExpect));
  77. }
  78. }
  79. };
  80. TEST_CLASS(UnitTest_4)
  81. {
  82. TEST_METHOD(TestMethode1)
  83. {
  84. char Section_Name[100][10] = { 0 };
  85. int Section_Count = CalcCount(100, Section_Name, FileName_4);
  86. CString Na, nExpect;
  87. for (int i = 0; i < Section_Count; i++) {
  88. GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_4);
  89. GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_4);
  90. bool nReal = IsPalindrome(_ttoi(Na));
  91. Assert::AreEqual(nReal, CstrToBool(nExpect));
  92. }
  93. }
  94. };
  95. TEST_CLASS(UnitTest_5)
  96. {
  97. TEST_METHOD(TestMethode1)
  98. {
  99. char Section_Name[100][10] = { 0 };
  100. int Section_Count = CalcCount(100, Section_Name, FileName_5);
  101. CString Na, nExpect;
  102. for (int i = 0; i < Section_Count; i++) {
  103. GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_5);
  104. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_5);
  105. char return_str[100][50] = { 0 };
  106. int return_count = str_device2(Na, return_str);
  107. TreeNode* root = CreatBitTree(return_str, return_count);
  108. int nReal = MinDepth(root);
  109. Assert::AreEqual(nReal,_ttoi(nExpect));
  110. free_tree(root);
  111. }
  112. }
  113. };
  114. TEST_CLASS(UnitTest_6)
  115. {
  116. TEST_METHOD(TestMethode1)
  117. {
  118. char Section_Name[100][10] = { 0 };
  119. int Section_Count = CalcCount(100, Section_Name, FileName_6);
  120. int array_count = 0;
  121. int* Section_Value;
  122. CString Na, Nb, nExpect;
  123. for (int i = 0; i < Section_Count; i++) {
  124. GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_6);
  125. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_6);
  126. Section_Value = str_device(Na, &array_count);
  127. bool nReal = containsDuplicate(Section_Value, array_count);
  128. Assert::AreEqual(nReal, CstrToBool(nExpect));
  129. }
  130. }
  131. };
  132. TEST_CLASS(UnitTest_7)
  133. {
  134. TEST_METHOD(TestMethode1)
  135. {
  136. char Section_Name[100][10] = { 0 };
  137. int Section_Count = CalcCount(100, Section_Name, FileName_7);
  138. CString Na, nExpect;
  139. for (int i = 0; i < Section_Count; i++) {
  140. GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_7);
  141. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(20), 20, FileName_7);
  142. char return_str[100][50] = { 0 };
  143. int return_count = str_device2(Na, return_str);
  144. TreeNode2* root = CreatBitTree2(return_str, return_count);
  145. int nReal = MaxDepth(root);
  146. Assert::AreEqual(nReal, _ttoi(nExpect));
  147. free_tree2(root);
  148. }
  149. }
  150. };
  151. TEST_CLASS(UnitTest_8)
  152. {
  153. TEST_METHOD(TestMethode1)
  154. {
  155. char Section_Name[100][10] = { 0 };
  156. int Section_Count = CalcCount(100, Section_Name, FileName_8);
  157. CString Na, nExpect;
  158. for (int i = 0; i < Section_Count; i++) {
  159. GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(20), 20, FileName_8);
  160. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(100), 100, FileName_8);
  161. int nReal = HammingWeight(_ttoi(Na));
  162. Assert::AreEqual(nReal, _ttoi(nExpect));
  163. }
  164. }
  165. };
  166. TEST_CLASS(UnitTest_9)
  167. {
  168. TEST_METHOD(TestMethode1)
  169. {
  170. char Section_Name[100][10] = { 0 };
  171. int Section_Count = CalcCount(100, Section_Name, FileName_9);
  172. CString input1,input2, output;
  173. for (int i = 0; i < Section_Count; i++) {
  174. GetPrivateProfileString(Section_Name[i], "input1", " ", input1.GetBuffer(100), 100, FileName_9);
  175. GetPrivateProfileString(Section_Name[i], "input2", " ", input2.GetBuffer(100), 100, FileName_9);
  176. GetPrivateProfileString(Section_Name[i], "output", " ", output.GetBuffer(200), 200, FileName_9);
  177. char p1[100];
  178. char p2[100];
  179. strcpy(p1, input1);
  180. strcpy(p2, input2);
  181. char* nReal = AddBinary(p1,p2);
  182. Assert::AreEqual(nReal, output);
  183. }
  184. }
  185. };
  186. TEST_CLASS(UnitTest_10)
  187. {
  188. TEST_METHOD(TestMethode1)
  189. {
  190. char Section_Name[100][10] = { 0 };
  191. int Section_Count = CalcCount(100, Section_Name, FileName_10);
  192. CString Na, nExpect;
  193. for (int i = 0; i < Section_Count; i++) {
  194. GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_10);
  195. GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(500), 500, FileName_10);
  196. char return_str[100][50] = { 0 };
  197. int return_count = str_device2(Na, return_str);
  198. TreeNode3* root = CreatBitTree3(return_str, return_count);
  199. int returnSize = 0;
  200. char** returnStr=NULL;
  201. returnStr = binaryTreePaths(root, &returnSize);
  202. char nReal[500] = { 0 };
  203. for (int i = 0; i < returnSize; i++)
  204. {
  205. strcat(nReal, returnStr[i]);
  206. if (i != (returnSize - 1))
  207. {
  208. nReal[strlen(nReal)] = ',';
  209. }
  210. }
  211. Assert::AreEqual(nReal,nExpect);
  212. free_tree3(root);
  213. }
  214. }
  215. };
  216. TEST_CLASS(UnitTest_11)
  217. {
  218. TEST_METHOD(TestMethode1)
  219. {
  220. char Section_Name[100][10] = { 0 };
  221. int Section_Count = CalcCount(100, Section_Name, FileName_11);
  222. CString input,output;
  223. for (int i = 0; i < Section_Count; i++) {
  224. GetPrivateProfileString(Section_Name[i], "input", " ", input.GetBuffer(20), 20, FileName_11);
  225. GetPrivateProfileString(Section_Name[i], "output", " ", output.GetBuffer(20), 20, FileName_11);
  226. bool nReal = CanWinNim(_ttoi(input));
  227. Assert::AreEqual(nReal, CstrToBool(output));
  228. }
  229. }
  230. };
  231. TEST_CLASS(UnitTest_12)
  232. {
  233. TEST_METHOD(TestMethode1)
  234. {
  235. char Section_Name[100][10] = { 0 };
  236. int Section_Count = CalcCount(100, Section_Name, FileName_12);
  237. char input_char[1024] = { 0 };
  238. CString input,output;
  239. for (int i = 0; i < Section_Count; i++) {
  240. GetPrivateProfileString(Section_Name[i], "input", " ", input.GetBuffer(200), 200, FileName_12);
  241. GetPrivateProfileString(Section_Name[i], "output", " ", output.GetBuffer(20), 20, FileName_12);
  242. strcpy(input_char, input);
  243. bool nReal = IsValid(input_char);
  244. Assert::AreEqual(nReal, CstrToBool(output));
  245. }
  246. }
  247. };
  248. TEST_CLASS(UnitTest_13)
  249. {
  250. TEST_METHOD(TestMethode1)
  251. {
  252. char Section_Name[100][10] = { 0 };
  253. int Section_Count = CalcCount(100, Section_Name, FileName_13);
  254. char input_char[1024] = { 0 };
  255. CString input, output;
  256. for (int i = 0; i < Section_Count; i++) {
  257. GetPrivateProfileString(Section_Name[i], "input", " ", input.GetBuffer(200), 200, FileName_13);
  258. GetPrivateProfileString(Section_Name[i], "output", " ", output.GetBuffer(20), 20, FileName_13);
  259. strcpy(input_char, input);
  260. int nReal = MyAtoi(input_char);
  261. Assert::AreEqual(nReal, _ttoi(output));
  262. }
  263. }
  264. };
  265. TEST_CLASS(UnitTest_14)
  266. {
  267. TEST_METHOD(TestMethode1)
  268. {
  269. char Section_Name[100][10] = { 0 };
  270. int Section_Count = CalcCount(100, Section_Name, FileName_14);
  271. int array_count = 0;
  272. int* Section_Value;
  273. CString input,output;
  274. for (int i = 0; i < Section_Count; i++) {
  275. GetPrivateProfileString(Section_Name[i], "input", " ", input.GetBuffer(200), 200, FileName_14);
  276. GetPrivateProfileString(Section_Name[i], "output", " ", output.GetBuffer(20), 20, FileName_14);
  277. Section_Value = str_device(input, &array_count);
  278. int nReal = SingleNumber(Section_Value, array_count);
  279. Assert::AreEqual(nReal, _ttoi(output));
  280. }
  281. }
  282. };
  283. TEST_CLASS(UnitTest_15)
  284. {
  285. TEST_METHOD(TestMethode1)
  286. {
  287. char Section_Name[100][10] = { 0 };
  288. int Section_Count = CalcCount(100, Section_Name, FileName_15);
  289. char Pattern_char[1024] = { 0 };
  290. char Str_char[1024] = { 0 };
  291. CString Pattern, Str, Output;
  292. for (int i = 0; i < Section_Count; i++) {
  293. GetPrivateProfileString(Section_Name[i], "Pattern", " ", Pattern.GetBuffer(200), 200, FileName_15);
  294. GetPrivateProfileString(Section_Name[i], "Str", " ", Str.GetBuffer(400), 400, FileName_15);
  295. GetPrivateProfileString(Section_Name[i], "Output", " ", Output.GetBuffer(20), 20, FileName_15);
  296. strcpy(Pattern_char, Pattern);
  297. strcpy(Str_char, Str);
  298. bool nReal = WordPattern(Pattern_char, Str_char);
  299. Assert::AreEqual(nReal, CstrToBool(Output));
  300. }
  301. }
  302. };
  303. TEST_CLASS(UnitTest_16)
  304. {
  305. TEST_METHOD(TestMethode1)
  306. {
  307. char Section_Name[100][10] = { 0 };
  308. int Section_Count = CalcCount(100, Section_Name, FileName_16);
  309. CString input,output;
  310. for (int i = 0; i < Section_Count; i++) {
  311. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(200), 200, FileName_16);
  312. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(200), 200, FileName_16);
  313. uint32_t nReal = ReverseBits((uint32_t)_atoi64(input));
  314. Assert::AreEqual(nReal, (uint32_t)_atoi64(output));
  315. }
  316. }
  317. };
  318. TEST_CLASS(UnitTest_17)
  319. {
  320. TEST_METHOD(TestMethode1)
  321. {
  322. char Section_Name[100][10] = { 0 };
  323. int Section_Count = CalcCount(100, Section_Name, FileName_17);
  324. CString Input1, Input2, Output;
  325. char Str_char[1024] = { 0 };
  326. char* WordDic[100];
  327. for (int i = 0; i < Section_Count; i++) {
  328. GetPrivateProfileString(Section_Name[i], "Input1", " ", Input1.GetBuffer(200), 200, FileName_17);
  329. GetPrivateProfileString(Section_Name[i], "Input2", " ", Input2.GetBuffer(500), 500, FileName_17);
  330. GetPrivateProfileString(Section_Name[i], "Output", " ", Output.GetBuffer(20), 20, FileName_17);
  331. strcpy(Str_char, Input1);
  332. int Wordic_count = str_device3(Input2, WordDic);
  333. bool nReal = WordBreak(Str_char, WordDic, Wordic_count);
  334. Assert::AreEqual(nReal, CstrToBool(Output));
  335. }
  336. }
  337. };
  338. TEST_CLASS(UnitTest_18)
  339. {
  340. TEST_METHOD(TestMethode1)
  341. {
  342. char Section_Name[100][10] = { 0 };
  343. int Section_Count = CalcCount(100, Section_Name, FileName_18);
  344. int input_count = 0, output_count = 0, returnSize = 0;
  345. int* input_value;
  346. int* output_value;
  347. CString input,output;
  348. for (int i = 0; i < Section_Count; i++) {
  349. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(200), 200, FileName_18);
  350. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(200), 200, FileName_18);
  351. input_value = str_device(input, &input_count);
  352. output_value = str_device(output, &output_count);
  353. int* nReal = PlusOne(input_value, input_count, &returnSize);
  354. for (int i = 0; i < input_count; i++) {
  355. Assert::AreEqual(nReal[i], output_value[i]);
  356. }
  357. }
  358. }
  359. };
  360. TEST_CLASS(UnitTest_19)
  361. {
  362. TEST_METHOD(TestMethode1)
  363. {
  364. char Section_Name[100][10] = { 0 };
  365. int Section_Count = CalcCount(100, Section_Name, FileName_19);
  366. CString input,output;
  367. for (int i = 0; i < Section_Count; i++) {
  368. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(100), 100, FileName_19);
  369. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(100), 100, FileName_19);
  370. int nReal = MySqrt(_ttoi(input));
  371. Assert::AreEqual(nReal, _ttoi(output));
  372. }
  373. }
  374. };
  375. TEST_CLASS(UnitTest_20)
  376. {
  377. TEST_METHOD(TestMethode1)
  378. {
  379. char Section_Name[100][10] = { 0 };
  380. int Section_Count = CalcCount(100, Section_Name, FileName_20);
  381. int input_count = 0, output_count = 0, returnSize = 0;
  382. int* input_value;
  383. int* output_value;
  384. CString input, output;
  385. for (int i = 0; i < Section_Count; i++) {
  386. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(200), 200, FileName_20);
  387. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(200), 200, FileName_20);
  388. input_value = str_device(input, &input_count);
  389. output_value = str_device(output, &output_count);
  390. MoveZeroes(input_value, input_count);
  391. for (int i = 0; i < input_count; i++) {
  392. Assert::AreEqual(input_value[i], output_value[i]);
  393. }
  394. }
  395. }
  396. };
  397. TEST_CLASS(UnitTest_21)
  398. {
  399. TEST_METHOD(TestMethode1)
  400. {
  401. char Section_Name[100][10] = { 0 };
  402. int Section_Count = CalcCount(100, Section_Name, FileName_21);
  403. CString input, output;
  404. for (int i = 0; i < Section_Count; i++) {
  405. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(100), 100, FileName_21);
  406. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(100), 100, FileName_21);
  407. int nReal = Reverse(_ttoi(input));
  408. Assert::AreEqual(nReal, _ttoi(output));
  409. }
  410. }
  411. };
  412. TEST_CLASS(UnitTest_22)
  413. {
  414. TEST_METHOD(TestMethode1)
  415. {
  416. char Section_Name[100][10] = { 0 };
  417. int Section_Count = CalcCount(100, Section_Name, FileName_22);
  418. int input_count = 0, output_count = 0, returnSize = 0;
  419. int* input_value;
  420. int* output_value;
  421. CString input, output,k;
  422. for (int i = 0; i < Section_Count; i++) {
  423. GetPrivateProfileString(Section_Name[i], "Input", " ", input.GetBuffer(200), 200, FileName_22);
  424. GetPrivateProfileString(Section_Name[i], "k", " ", k.GetBuffer(20), 20, FileName_22);
  425. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(200), 200, FileName_22);
  426. input_value = str_device(input, &input_count);
  427. output_value = str_device(output, &output_count);
  428. Rotate1(input_value, input_count, _ttoi(k));
  429. for (int i = 0; i < input_count; i++) {
  430. Assert::AreEqual(input_value[i], output_value[i]);
  431. }
  432. }
  433. }
  434. };
  435. TEST_CLASS(UnitTest_23)
  436. {
  437. TEST_METHOD(TestMethode1)
  438. {
  439. char Section_Name[100][10] = { 0 };
  440. int Section_Count = CalcCount(100, Section_Name, FileName_23);
  441. CString Input, Output;
  442. char Str_char[20];
  443. char** return_char ;
  444. int return_len = 0;
  445. char output_char[100][50];
  446. int output_len = 0;
  447. for (int i = 0; i < Section_Count; i++) {
  448. GetPrivateProfileString(Section_Name[i], "Input", " ", Input.GetBuffer(20), 20, FileName_23);
  449. GetPrivateProfileString(Section_Name[i], "Output", " ", Output.GetBuffer(1024), 1024, FileName_23);
  450. output_len = str_device2(Output, output_char);
  451. strcpy(Str_char, Input);
  452. return_char = RestoreIpAddresses(Str_char, &return_len);
  453. Assert::AreEqual(return_len, output_len); //先判断个数是否相等
  454. for (int j = 0; j < return_len; j++) { //循环挨个比较
  455. Assert::AreEqual(return_char[j], output_char[j]);
  456. }
  457. }
  458. }
  459. };
  460. TEST_CLASS(UnitTest_24)
  461. {
  462. TEST_METHOD(TestMethode1)
  463. {
  464. char Section_Name[100][10] = { 0 };
  465. int Section_Count = CalcCount(100, Section_Name, FileName_24);
  466. CString Input, Output;
  467. char Str_char[1024] = { 0 };
  468. char* WordDic[100];
  469. for (int i = 0; i < Section_Count; i++) {
  470. GetPrivateProfileString(Section_Name[i], "Input", " ", Input.GetBuffer(200), 200, FileName_24);
  471. GetPrivateProfileString(Section_Name[i], "Output", " ", Output.GetBuffer(20), 20, FileName_24);
  472. strcpy(Str_char, Input);
  473. int nReal = LengthOfLongestSubstring(Str_char);
  474. Assert::AreEqual(nReal, _ttoi(Output));
  475. }
  476. }
  477. };
  478. TEST_CLASS(UnitTest_25)
  479. {
  480. TEST_METHOD(TestMethode1)
  481. {
  482. char Section_Name[100][10] = { 0 };
  483. int Section_Count = CalcCount(100, Section_Name, FileName_25);
  484. int input_count = 0, output_count = 0, returnSize = 0;
  485. int* input_value;
  486. int* output_value;
  487. CString input1, input2,output;
  488. for (int i = 0; i < Section_Count; i++) {
  489. GetPrivateProfileString(Section_Name[i], "Input1", " ", input1.GetBuffer(200), 200, FileName_25);
  490. GetPrivateProfileString(Section_Name[i], "Input2", " ", input2.GetBuffer(20), 20, FileName_25);
  491. GetPrivateProfileString(Section_Name[i], "Output", " ", output.GetBuffer(200), 200, FileName_25);
  492. input_value = str_device(input1, &input_count);
  493. output_value = str_device(output, &output_count);
  494. struct ListNode* head = (struct ListNode*)malloc(sizeof(struct ListNode));
  495. CreatListNode(input_value,input_count,head);
  496. struct ListNode* returnHead = Partition(head, atoi(input2));
  497. Assert::AreEqual(input_count, output_count);
  498. for (int i = 0; i < input_count; i++) {
  499. Assert::AreEqual(returnHead->val, output_value[i]);
  500. returnHead = returnHead->next;
  501. }
  502. }
  503. }
  504. };
  505. }