ArrayTests.cpp 596 B

1234567891011121314151617181920212223242526272829303132
  1. #include "tests/ArrayTests.h"
  2. #include "data/Array.h"
  3. #include "test/Test.h"
  4. using String = Core::ArrayString<128>;
  5. template<typename T>
  6. static String build(const T& t) {
  7. String s;
  8. CORE_TEST_FALSE(s.append(t));
  9. return s;
  10. }
  11. static void testToString1() {
  12. Core::Array<int, 3> a;
  13. a[0] = 1;
  14. a[1] = 243;
  15. a[2] = -423;
  16. CORE_TEST_EQUAL(build("[1, 243, -423]"), build(a));
  17. }
  18. static void testToString2() {
  19. Core::Array<int, 1> a;
  20. a[0] = 1;
  21. CORE_TEST_EQUAL(build("[1]"), build(a));
  22. }
  23. void Core::ArrayTests::test() {
  24. testToString1();
  25. testToString2();
  26. }