dumatestpp.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #include <stdio.h>
  2. #include <fstream>
  3. #include <new>
  4. #ifndef DUMA_SO_LIBRARY
  5. #include "../dumapp.h"
  6. #endif /* ifndef DUMA_SO_LIBRARY */
  7. #if 0
  8. class test
  9. {
  10. public:
  11. test()
  12. {
  13. x = 0;
  14. }
  15. test(int m)
  16. {
  17. x = m;
  18. }
  19. ~test()
  20. {
  21. x = 0;
  22. }
  23. int x;
  24. };
  25. class testtest
  26. {
  27. public:
  28. testtest()
  29. {
  30. y = new test; //NEW_ELEM( test ); //new test();
  31. }
  32. testtest(int m)
  33. {
  34. y = new test(m); //NEW_ELEM( test(m) ); //new test(m);
  35. }
  36. ~testtest()
  37. {
  38. delete y;
  39. }
  40. test *y;
  41. };
  42. #endif /* if 0 */
  43. int
  44. main(int argc, char **argv)
  45. {
  46. (void)argc;
  47. (void)argv;
  48. #if 0
  49. int * x = 0;
  50. int ret;
  51. ret = posix_memalign(&x, 2048, sizeof ( int ) );
  52. if ( !ret )
  53. {
  54. *x = 1;
  55. }
  56. free(x);
  57. #elif 0
  58. #include "noduma.h"
  59. int *x = 0;
  60. x = new int[10];
  61. x[0] = 0;
  62. delete x;
  63. #elif 0
  64. std::fstream *f = new std::fstream();
  65. delete f;
  66. #elif 0
  67. /* this test should fail */
  68. int i;
  69. CA_DEFINE(int, acTest, 20);
  70. for (i = 0; i < 100; ++i)
  71. {
  72. CA_REF(acTest, i) = i;
  73. }
  74. #elif 0
  75. /* this test should not fail */
  76. int *y, *z;
  77. y = new int;
  78. z = new int[2];
  79. DEL_ARRAY(z);
  80. DEL_ARRAY(z);
  81. DEL_ELEM(y);
  82. DEL_ELEM(y);
  83. #elif 1
  84. int *y, *z;
  85. y = new int;
  86. z = new int[2];
  87. delete[] z;
  88. delete y;
  89. #elif 0
  90. int *y, *z;
  91. y = new int;
  92. z = new int[2];
  93. DEL_ARRAY(z);
  94. DEL_ELEM(y);
  95. // y = new int;
  96. // DEL_ELEM(y);
  97. // DEL_ELEM(y);
  98. // y = new(__FILE__,__LINE__) int;
  99. // delete (__FILE__, __LINE__, y);
  100. // y = new(std::nothrow) int;
  101. // delete (std::nothrow, y);
  102. // y = new(std::nothrow, __FILE__, __LINE__) int;
  103. // delete (std::nothrow, __FILE__, __LINE__, y);
  104. #elif 0
  105. /* this test should not fail */
  106. int *y;
  107. y = NEW_ARRAY(int, 2);
  108. DEL_ARRAY(y);
  109. #elif 0
  110. /* this test should not fail */
  111. int *x, *y;
  112. test *z;
  113. x = (int *)malloc(sizeof ( int ));
  114. y = new int;
  115. z = new test[2];
  116. free(x);
  117. delete y;
  118. delete[] z;
  119. #elif 0
  120. /* this test should not fail */
  121. test *x = new test(10);
  122. test *ax = new test[2];
  123. testtest *y = new testtest;
  124. delete y;
  125. delete[] ax;
  126. delete x;
  127. #endif /* if 0 */
  128. return ( 0 );
  129. }