HeapArrayTests.cpp 616 B

123456789101112131415161718192021222324252627
  1. #include "tests/HeapArrayTests.h"
  2. #include "tests/Test.h"
  3. #include "utils/HeapArray.h"
  4. #include "utils/StringBuffer.h"
  5. typedef StringBuffer<50> String;
  6. static void testToString1(Test& test) {
  7. HeapArray<int> a(3);
  8. a[0] = 1;
  9. a[1] = 243;
  10. a[2] = -423;
  11. test.checkEqual(String("[1, 243, -423]"), String(a), "to string 1");
  12. }
  13. static void testToString2(Test& test) {
  14. HeapArray<int> a(1);
  15. a[0] = 1;
  16. test.checkEqual(String("[1]"), String(a), "to string 2");
  17. }
  18. void HeapArrayTests::test() {
  19. Test test("HeapArray");
  20. testToString1(test);
  21. testToString2(test);
  22. test.finalize();
  23. }