Eric Fiselier | 257fd69 | 2016-05-07 01:04:55 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // UNSUPPORTED: c++98, c++03 |
| 11 | |
| 12 | // <experimental/memory_resource> |
| 13 | |
| 14 | // bool operator!=(memory_resource const &, memory_resource const &) noexcept; |
| 15 | |
| 16 | #include <experimental/memory_resource> |
| 17 | #include <type_traits> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_memory_resource.hpp" |
| 21 | |
| 22 | namespace ex = std::experimental::pmr; |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | // check return types |
| 27 | { |
| 28 | ex::memory_resource const * mr1(nullptr); |
| 29 | ex::memory_resource const * mr2(nullptr); |
| 30 | static_assert(std::is_same<decltype(*mr1 != *mr2), bool>::value, ""); |
| 31 | static_assert(noexcept(*mr1 != *mr2), ""); |
| 32 | } |
| 33 | // not equal |
| 34 | { |
| 35 | TestResource r1(1); |
| 36 | TestResource r2(2); |
| 37 | ex::memory_resource const & mr1 = r1; |
| 38 | ex::memory_resource const & mr2 = r2; |
| 39 | |
| 40 | assert(mr1 != mr2); |
| 41 | assert(r1.checkIsEqualCalledEq(1)); |
| 42 | assert(r2.checkIsEqualCalledEq(0)); |
| 43 | |
| 44 | assert(mr2 != mr1); |
| 45 | assert(r1.checkIsEqualCalledEq(1)); |
| 46 | assert(r2.checkIsEqualCalledEq(1)); |
| 47 | } |
| 48 | // equal |
| 49 | { |
| 50 | TestResource r1(1); |
| 51 | TestResource r2(1); |
| 52 | ex::memory_resource const & mr1 = r1; |
| 53 | ex::memory_resource const & mr2 = r2; |
| 54 | |
| 55 | assert(!(mr1 != mr2)); |
| 56 | assert(r1.checkIsEqualCalledEq(1)); |
| 57 | assert(r2.checkIsEqualCalledEq(0)); |
| 58 | |
| 59 | assert(!(mr2 != mr1)); |
| 60 | assert(r1.checkIsEqualCalledEq(1)); |
| 61 | assert(r2.checkIsEqualCalledEq(1)); |
| 62 | } |
| 63 | // equal same object |
| 64 | { |
| 65 | TestResource r1(1); |
| 66 | ex::memory_resource const & mr1 = r1; |
| 67 | ex::memory_resource const & mr2 = r1; |
| 68 | |
| 69 | assert(!(mr1 != mr2)); |
| 70 | assert(r1.checkIsEqualCalledEq(0)); |
| 71 | |
| 72 | assert(!(mr2 != mr1)); |
| 73 | assert(r1.checkIsEqualCalledEq(0)); |
| 74 | } |
| 75 | } |