| 1 | /* |
| 2 | Copyright (c) 2005-2019 Intel Corporation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // Test whether cache_aligned_allocator works with some of the host's STL containers. |
| 18 | |
| 19 | #include "tbb/cache_aligned_allocator.h" |
| 20 | #include "tbb/tbb_allocator.h" |
| 21 | |
| 22 | #define HARNESS_NO_PARSE_COMMAND_LINE 1 |
| 23 | #include "test_allocator_STL.h" |
| 24 | |
| 25 | int TestMain () { |
| 26 | TestAllocatorWithSTL<tbb::cache_aligned_allocator<void> >(); |
| 27 | TestAllocatorWithSTL<tbb::tbb_allocator<void> >(); |
| 28 | TestAllocatorWithSTL<tbb::zero_allocator<void> >(); |
| 29 | |
| 30 | #if __TBB_CPP17_MEMORY_RESOURCE_PRESENT |
| 31 | tbb::cache_aligned_resource aligned_resource; |
| 32 | tbb::cache_aligned_resource equal_aligned_resource(std::pmr::get_default_resource()); |
| 33 | ASSERT(aligned_resource.is_equal(equal_aligned_resource), |
| 34 | "Underlying upstream resources should be equal." ); |
| 35 | ASSERT(!aligned_resource.is_equal(*std::pmr::null_memory_resource()), |
| 36 | "Cache aligned resource upstream shouldn't be equal to the standard resource." ); |
| 37 | TestAllocatorWithSTL(std::pmr::polymorphic_allocator<void>(&aligned_resource)); |
| 38 | #endif |
| 39 | |
| 40 | return Harness::Done; |
| 41 | } |
| 42 | |
| 43 | |