1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 // UNSUPPORTED: libcpp-has-no-incomplete-ranges 11 12 // General tests for join_view. This file does not test anything specifically. 13 14 #include <algorithm> 15 #include <cassert> 16 #include <ranges> 17 #include <string> 18 #include <vector> 19 20 #include "test_macros.h" 21 #include "types.h" 22 23 24 template<class R, class I> 25 bool isEqual(R &r, I i) { 26 for (auto e : r) 27 if (e != *i++) 28 return false; 29 return true; 30 } 31 32 int main(int, char**) { 33 { 34 int buffer[4][4] = {{1111, 2222, 3333, 4444}, {555, 666, 777, 888}, {99, 1010, 1111, 1212}, {13, 14, 15, 16}}; 35 int *flattened = reinterpret_cast<int*>(buffer); 36 37 ChildView children[4] = {ChildView(buffer[0]), ChildView(buffer[1]), ChildView(buffer[2]), ChildView(buffer[3])}; 38 auto jv = std::ranges::join_view(ParentView(children)); 39 assert(isEqual(jv, flattened)); 40 } 41 42 { 43 std::vector<std::string> vec = {"Hello", ",", " ", "World", "!"}; 44 std::string check = "Hello, World!"; 45 std::ranges::join_view jv(vec); 46 assert(isEqual(jv, check.begin())); 47 } 48 49 return 0; 50 } 51