X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/eb6b6ca394357805f2bdba989abae309f718b4d8..f427ee49d309d8fc33ebf3042c3a775f2f530ded:/tests/safe_allocation_src/compare.equal.nullptr.cpp?ds=inline diff --git a/tests/safe_allocation_src/compare.equal.nullptr.cpp b/tests/safe_allocation_src/compare.equal.nullptr.cpp new file mode 100644 index 000000000..4a77169d5 --- /dev/null +++ b/tests/safe_allocation_src/compare.equal.nullptr.cpp @@ -0,0 +1,45 @@ +// +// Tests for +// template +// bool operator==(std::nullptr_t, safe_allocation const& x); +// +// template +// bool operator!=(std::nullptr_t, safe_allocation const& x); +// +// template +// bool operator==(safe_allocation const& x, std::nullptr_t); +// +// template +// bool operator!=(safe_allocation const& x, std::nullptr_t); +// + +#include +#include +#include "test_utils.h" + +struct T { }; + +template +static void +tests() +{ + { + test_safe_allocation const array(10, libkern::allocate_memory); + CHECK(!(array == nullptr)); + CHECK(!(nullptr == array)); + CHECK(array != nullptr); + CHECK(nullptr != array); + } + { + test_safe_allocation const array = nullptr; + CHECK(array == nullptr); + CHECK(nullptr == array); + CHECK(!(array != nullptr)); + CHECK(!(nullptr != array)); + } +} + +T_DECL(compare_equal_nullptr, "safe_allocation.compare.equal.nullptr") { + tests(); + tests(); +}