summaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/array
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:08 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:08 +0000
commit0564cdb94a7a1facbb0dbf888ceb90638aa70ecd (patch)
tree3ccbf1ba827928fca93419d0b6cf83ce0f650f2a /test/std/containers/sequences/array
parentdbabdb5220c44e5938d404eefb84b5ed55667ea8 (diff)
Notes
Diffstat (limited to 'test/std/containers/sequences/array')
-rw-r--r--test/std/containers/sequences/array/at.pass.cpp6
-rw-r--r--test/std/containers/sequences/array/empty.fail.cpp28
-rw-r--r--test/std/containers/sequences/array/empty.pass.cpp36
-rw-r--r--test/std/containers/sequences/array/front_back.pass.cpp4
-rw-r--r--test/std/containers/sequences/array/indexing.pass.cpp2
-rw-r--r--test/std/containers/sequences/array/max_size.pass.cpp36
6 files changed, 106 insertions, 6 deletions
diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp
index efec4e403001..27b326fa7ce4 100644
--- a/test/std/containers/sequences/array/at.pass.cpp
+++ b/test/std/containers/sequences/array/at.pass.cpp
@@ -27,7 +27,7 @@
constexpr bool check_idx( size_t idx, double val )
{
std::array<double, 3> arr = {1, 2, 3.5};
- return arr.at(idx) == val;
+ return arr.at(idx) == val;
}
#endif
@@ -50,7 +50,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
- (void) c.at(3);
+ TEST_IGNORE_NODISCARD c.at(3);
assert(false);
}
catch (const std::out_of_range &) {}
@@ -69,7 +69,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
- (void) c.at(3);
+ TEST_IGNORE_NODISCARD c.at(3);
assert(false);
}
catch (const std::out_of_range &) {}
diff --git a/test/std/containers/sequences/array/empty.fail.cpp b/test/std/containers/sequences/array/empty.fail.cpp
new file mode 100644
index 000000000000..85bf5a7c9dab
--- /dev/null
+++ b/test/std/containers/sequences/array/empty.fail.cpp
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// class array
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <array>
+
+#include "test_macros.h"
+
+int main ()
+{
+ std::array<int, 1> c;
+ c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
diff --git a/test/std/containers/sequences/array/empty.pass.cpp b/test/std/containers/sequences/array/empty.pass.cpp
new file mode 100644
index 000000000000..2c01dfc86c19
--- /dev/null
+++ b/test/std/containers/sequences/array/empty.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// class array
+
+// bool empty() const noexcept;
+
+#include <array>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::array<int, 2> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(!c.empty());
+ }
+ {
+ typedef std::array<int, 0> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert( c.empty());
+ }
+}
diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp
index 68fc6cdc4543..0591ca7fac31 100644
--- a/test/std/containers/sequences/array/front_back.pass.cpp
+++ b/test/std/containers/sequences/array/front_back.pass.cpp
@@ -27,13 +27,13 @@
constexpr bool check_front( double val )
{
std::array<double, 3> arr = {1, 2, 3.5};
- return arr.front() == val;
+ return arr.front() == val;
}
constexpr bool check_back( double val )
{
std::array<double, 3> arr = {1, 2, 3.5};
- return arr.back() == val;
+ return arr.back() == val;
}
#endif
diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp
index 3a5b9ee9727d..43c494777a9d 100644
--- a/test/std/containers/sequences/array/indexing.pass.cpp
+++ b/test/std/containers/sequences/array/indexing.pass.cpp
@@ -27,7 +27,7 @@
constexpr bool check_idx( size_t idx, double val )
{
std::array<double, 3> arr = {1, 2, 3.5};
- return arr[idx] == val;
+ return arr[idx] == val;
}
#endif
diff --git a/test/std/containers/sequences/array/max_size.pass.cpp b/test/std/containers/sequences/array/max_size.pass.cpp
new file mode 100644
index 000000000000..9a3fed3950e3
--- /dev/null
+++ b/test/std/containers/sequences/array/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// class array
+
+// bool max_size() const noexcept;
+
+#include <array>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::array<int, 2> C;
+ C c;
+ ASSERT_NOEXCEPT(c.max_size());
+ assert(c.max_size() == 2);
+ }
+ {
+ typedef std::array<int, 0> C;
+ C c;
+ ASSERT_NOEXCEPT(c.max_size());
+ assert(c.max_size() == 0);
+ }
+}