diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/assign.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/assign.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/assign.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// reference& operator=(const reference&) + +#include +#include + +int main(int, char**) { + std::vector vec; + typedef std::vector::reference Ref; + vec.push_back(true); + vec.push_back(false); + Ref ref1 = vec[0]; + Ref ref2 = vec[1]; + ref2 = ref1; + assert(ref2); + assert(vec[1]); +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/bool_assign.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/bool_assign.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/bool_assign.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// reference& operator=(bool) + +#include +#include + +int main(int, char**) { + std::vector vec; + typedef std::vector::reference Ref; + vec.push_back(true); + Ref ref = vec[0]; + const Ref cref = vec[0]; + + assert(ref); + ref = false; + assert(!ref); + + assert(!cref); +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/copy_ctor.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/copy_ctor.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/copy_ctor.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// reference(const reference&) + +#include +#include + +int main(int, char**) { + std::vector vec; + typedef std::vector::reference Ref; + vec.push_back(true); + Ref ref = vec[0]; + Ref ref2 = ref; + assert(ref == ref2); +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// flip() + +#include +#include + +int main(int, char**) { + std::vector vec; + typedef std::vector::reference Ref; + vec.push_back(true); + Ref ref = vec[0]; + assert(ref); + ref.flip(); + assert(!ref); + ref.flip(); + assert(ref); +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// operator bool() + +#include +#include + +int main(int, char**) { + std::vector vec; + typedef std::vector::reference Ref; + vec.push_back(true); + vec.push_back(false); + Ref true_ref = vec[0]; + Ref false_ref = vec[1]; + assert(true_ref); + assert(!false_ref); +}