12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include "../Tests.hpp"
- #include "core/data/Array.hpp"
- template class Core::Array<int, 3>;
- static void testToString1() {
- Core::Array<int, 3> a;
- a[0] = 1;
- a[1] = 243;
- a[2] = -423;
- CORE_TEST_STRING("[1, 243, -423]", a);
- }
- static void testToString2() {
- Core::Array<int, 1> a;
- a[0] = 1;
- CORE_TEST_STRING("[1]", a);
- }
- static void testReadConst() {
- Core::Array<int, 3> a;
- for(int i = 0; i < a.getLength(); i++) {
- a[i] = i;
- }
- const Core::Array<int, 3>& c = a;
- for(int i = 0; i < c.getLength(); i++) {
- CORE_TEST_EQUAL(i, c[i]);
- }
- }
- static void testRangeFor() {
- Core::Array<int, 3> a;
- for(int i = 0; i < a.getLength(); i++) {
- a[i] = i;
- }
- for(int& i : a) {
- i++;
- }
- for(int i = 0; i < a.getLength(); i++) {
- CORE_TEST_EQUAL(i + 1, a[i]);
- }
- }
- void Core::testArray() {
- testToString1();
- testToString2();
- testReadConst();
- testRangeFor();
- }
|