ArrayTests.cpp 650 B

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