Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

93 Zeilen
2.5 KiB

  1. #include "stdafx.h"
  2. #include "CppUnitTest.h"
  3. #include "Windows.h"
  4. #include"../jia/jia.h"
  5. #include"../jian/jian.h"
  6. #include"../chen/chen.h"
  7. #include"../chu/chu.h"
  8. using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  9. namespace UnitTest1
  10. {
  11. TEST_CLASS(UnitTest1)
  12. {
  13. public:
  14. TEST_METHOD(TestMethod1)
  15. {
  16. // TODO: ÔÚ´ËÊäÈë²âÊÔ´úÂë
  17. int SUM = GetPrivateProfileInt("Len", "sum", 0, "../ex1.ini");
  18. {
  19. for (int i = 1; i <= SUM; i++)
  20. {
  21. char SUMStr[8];
  22. char TestStr[8] = { "Test" };
  23. _itoa_s(i, SUMStr, 8);
  24. strcat_s(TestStr, SUMStr);
  25. int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex1.ini");
  26. int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex1.ini");
  27. int output = GetPrivateProfileInt("TestStr", "output", 0, "ex1.ini");
  28. Assert::AreEqual(output, add(num1, num2));
  29. }
  30. }
  31. }
  32. TEST_METHOD(TestMethod2)
  33. {
  34. int SUB = GetPrivateProfileInt("Len", "sum", 0, "../ex2.ini");
  35. {
  36. for (int j = 1; j <= SUB; j++)
  37. {
  38. char SUBStr[8];
  39. char TestStr[8] = { "Test" };
  40. _itoa_s(j, SUBStr, 8);
  41. strcat_s(TestStr, SUBStr);
  42. int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex2.ini");
  43. int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex2.ini");
  44. int output = GetPrivateProfileInt("TestStr", "output", 0, "ex2.ini");
  45. Assert::AreEqual(output, sub(num1, num2));
  46. }
  47. }
  48. }
  49. TEST_METHOD(TestMethod3)
  50. {
  51. int MUL = GetPrivateProfileInt("Len", "sum", 0, "../ex3.ini");
  52. {
  53. for (int i = 1; i <= MUL; i++)
  54. {
  55. char MULStr[8];
  56. char TestStr[8] = { "Test" };
  57. _itoa_s(i, MULStr, 8);
  58. strcat_s(TestStr, MULStr);
  59. int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex3.ini");
  60. int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex3.ini");
  61. int output = GetPrivateProfileInt("TestStr", "output", 0, "ex3.ini");
  62. Assert::AreEqual(output, mul(num1, num2));
  63. }
  64. }
  65. }
  66. TEST_METHOD(TestMethod4)
  67. {
  68. int DIV = GetPrivateProfileInt("Len", "sum", 0, "../ex4.ini");
  69. {
  70. for (int i = 1; i <= DIV; i++)
  71. {
  72. char DIVStr[8];
  73. char TestStr[8] = { "Test" };
  74. _itoa_s(i, DIVStr, 8);
  75. strcat_s(TestStr, DIVStr);
  76. int num1 = GetPrivateProfileInt("TestStr", "number1", 0, "ex4.ini");
  77. int num2 = GetPrivateProfileInt("TestStr", "number2", 0, "ex4.ini");
  78. int output = GetPrivateProfileInt("TestStr", "output", 0, "ex4.ini");
  79. Assert::AreEqual(output, chu(num1, num2));
  80. }
  81. }
  82. }
  83. };
  84. }