ArrayTests.cpp 604 B

123456789101112131415161718192021222324252627
  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. test.checkEqual(String("[1, 243, -423]"), String(a), "array to string 1");
  12. }
  13. static void testToString2(Test& test) {
  14. Array<int, 1> a;
  15. a[0] = 1;
  16. test.checkEqual(String("[1]"), String(a), "array to string 2");
  17. }
  18. void ArrayTests::test() {
  19. Test test("Array");
  20. testToString1(test);
  21. testToString2(test);
  22. test.finalize();
  23. }