Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

memory_test.cpp 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : MTK
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : memory_test
  9. * License : No use w/o permission (C) 2002 Mongoose
  10. * Comments: Memory testing tool kit
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- History -------------------------------------------------
  17. *
  18. * 2002.03.27:
  19. * Mongoose - Created
  20. =================================================================*/
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <memory_test.h>
  25. #define PRINT_TEST_BREAK_LINE printf("\n############################################################\n\n");
  26. int memory_test_unit_test(int argc, char *argv[])
  27. {
  28. int *i, *j, *k, *l, *m, *n, *o;
  29. PRINT_TEST_BREAK_LINE
  30. printf("Memory test\n");
  31. PRINT_TEST_BREAK_LINE
  32. printf(">\ti = new int; %s:%i\n", __FILE__, __LINE__);
  33. i = new int;
  34. dump_memory_report();
  35. tree_valid_report(MEMORY_INFO);
  36. printf(">\tdelete i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  37. delete i;
  38. dump_memory_report();
  39. tree_valid_report(MEMORY_INFO);
  40. PRINT_TEST_BREAK_LINE
  41. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  42. i = new int[3];
  43. dump_memory_report();
  44. tree_valid_report(MEMORY_INFO);
  45. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  46. delete [] i;
  47. dump_memory_report();
  48. tree_valid_report(MEMORY_INFO);
  49. PRINT_TEST_BREAK_LINE
  50. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  51. i = new int[3];
  52. printf(">\tj = new int; (%p) %s:%i\n", j, __FILE__, __LINE__);
  53. j = new int;
  54. printf(">\tk = new int[3]; (%p) %s:%i\n", k, __FILE__, __LINE__);
  55. k = new int[3];
  56. dump_memory_report();
  57. tree_valid_report(MEMORY_INFO);
  58. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  59. delete [] i;
  60. printf(">\tdelete j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  61. delete j;
  62. printf(">\tdelete [] k; (%p) %s:%i\n", k, __FILE__, __LINE__);
  63. delete [] k;
  64. dump_memory_report();
  65. tree_valid_report(MEMORY_INFO);
  66. PRINT_TEST_BREAK_LINE
  67. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  68. i = new int[3];
  69. printf(">\tj = new int; (%p) %s:%i\n", j, __FILE__, __LINE__);
  70. j = new int;
  71. printf(">\tk = new int[3]; (%p) %s:%i\n", k, __FILE__, __LINE__);
  72. k = new int[3];
  73. dump_memory_report();
  74. tree_valid_report(MEMORY_INFO);
  75. printf(">\tdelete j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  76. delete j;
  77. dump_memory_report();
  78. tree_valid_report(MEMORY_INFO);
  79. printf(">\tj = new int[3]; (%p) %s:%i\n", j, __FILE__, __LINE__);
  80. j = new int[3];
  81. dump_memory_report();
  82. tree_valid_report(MEMORY_INFO);
  83. printf(">\tl = new int[3]; (%p) %s:%i\n", l, __FILE__, __LINE__);
  84. l = new int[3];
  85. dump_memory_report();
  86. tree_valid_report(MEMORY_INFO);
  87. printf(">\tm = new int[3]; (%p) %s:%i\n", m, __FILE__, __LINE__);
  88. m = new int[3];
  89. dump_memory_report();
  90. tree_valid_report(MEMORY_INFO);
  91. printf(">\tn = new int[3]; (%p) %s:%i\n", n, __FILE__, __LINE__);
  92. n = new int[3];
  93. dump_memory_report();
  94. tree_valid_report(MEMORY_INFO);
  95. printf(">\to = new int[3]; (%p) %s:%i\n", o, __FILE__, __LINE__);
  96. o = new int[3];
  97. dump_memory_report();
  98. tree_valid_report(MEMORY_INFO);
  99. printf(">\tdelete [] k; (%p) %s:%i\n", k, __FILE__, __LINE__);
  100. delete [] k;
  101. dump_memory_report();
  102. tree_valid_report(MEMORY_INFO);
  103. printf(">\tdelete [] j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  104. delete [] j;
  105. dump_memory_report();
  106. tree_valid_report(MEMORY_INFO);
  107. printf(">\tdelete [] l; (%p) %s:%i\n", l, __FILE__, __LINE__);
  108. delete [] l;
  109. dump_memory_report();
  110. tree_valid_report(MEMORY_INFO);
  111. printf(">\tdelete [] m; (%p) %s:%i\n", m, __FILE__, __LINE__);
  112. delete [] m;
  113. dump_memory_report();
  114. tree_valid_report(MEMORY_INFO);
  115. printf(">\tdelete [] n; (%p) %s:%i\n", n, __FILE__, __LINE__);
  116. delete [] n;
  117. dump_memory_report();
  118. tree_valid_report(MEMORY_INFO);
  119. printf(">\tdelete [] o; (%p) %s:%i\n", o, __FILE__, __LINE__);
  120. delete [] o;
  121. dump_memory_report();
  122. tree_valid_report(MEMORY_INFO);
  123. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  124. delete [] i;
  125. dump_memory_report();
  126. tree_valid_report(MEMORY_INFO);
  127. PRINT_TEST_BREAK_LINE
  128. return 0;
  129. }
  130. int main(int argc, char *argv[])
  131. {
  132. printf("[memory_test test]\n");
  133. return memory_test_unit_test(argc, argv);
  134. }