| 34 | namespace std::test |
| 35 | { |
| 36 | bool array_test::run(bool report) |
| 37 | { |
| 38 | report_ = report; |
| 39 | start(); |
| 40 | |
| 41 | auto check1 = {1, 2, 3, 4}; |
| 42 | auto check2 = {4, 3, 2, 1}; |
| 43 | auto check3 = {5, 5, 5, 5}; |
| 44 | |
| 45 | std::array<int, 4> arr1{1, 2, 3, 4}; |
| 46 | test_eq( |
| 47 | "initializer list construction", |
| 48 | arr1.begin(), arr1.end(), |
| 49 | check1.begin(), check1.end() |
| 50 | ); |
| 51 | |
| 52 | auto it = arr1.begin(); |
| 53 | test_eq( |
| 54 | "iterator increment", |
| 55 | *(++it), arr1[1] |
| 56 | ); |
| 57 | test_eq( |
| 58 | "iterator decrement", |
| 59 | *(--it), arr1[0] |
| 60 | ); |
| 61 | |
| 62 | std::array<int, 4> arr2{arr1}; |
| 63 | test_eq( |
| 64 | "copy construction", |
| 65 | arr1.begin(), arr1.end(), |
| 66 | arr2.begin(), arr2.end() |
| 67 | ); |
| 68 | |
| 69 | std::reverse(arr2.begin(), arr2.end()); |
| 70 | test_eq( |
| 71 | "reverse", |
| 72 | arr2.begin(), arr2.end(), |
| 73 | check2.begin(), check2.end() |
| 74 | ); |
| 75 | test_eq( |
| 76 | "reverse iterator", |
| 77 | arr1.rbegin(), arr1.rend(), |
| 78 | arr2.begin(), arr2.end() |
| 79 | ); |
| 80 | |
| 81 | |
| 82 | std::array<int, 4> arr3{}; |
| 83 | arr3.fill(5); |
| 84 | test_eq( |
| 85 | "fill", |
| 86 | arr3.begin(), arr3.end(), |
| 87 | check3.begin(), check3.end() |
| 88 | ); |
| 89 | |
| 90 | arr2.swap(arr3); |
| 91 | test_eq( |
| 92 | "swap part 1", |
| 93 | arr2.begin(), arr2.end(), |