ArrayTests.cpp 795 B

1234567891011121314151617181920212223242526272829303132333435
  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(Core::Test& test, const T& t) {
  7. String s;
  8. test.checkFalse(s.append(t), "append works");
  9. return s;
  10. }
  11. static void testToString1(Core::Test& test) {
  12. Core::Array<int, 3> a;
  13. a[0] = 1;
  14. a[1] = 243;
  15. a[2] = -423;
  16. test.checkEqual(build(test, "[1, 243, -423]"), build(test, a),
  17. "to string 1");
  18. }
  19. static void testToString2(Core::Test& test) {
  20. Core::Array<int, 1> a;
  21. a[0] = 1;
  22. test.checkEqual(build(test, "[1]"), build(test, a), "to string 2");
  23. }
  24. void Core::ArrayTests::test() {
  25. Core::Test test("Array");
  26. testToString1(test);
  27. testToString2(test);
  28. test.finalize();
  29. }