Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69485 - in sandbox/enums/libs/enums/test: . enum_array enum_array/cons enum_array/data enum_array/fill enum_array/size enum_array/special enum_array/swap
From: vicente.botet_at_[hidden]
Date: 2011-03-02 12:14:57


Author: viboes
Date: 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
New Revision: 69485
URL: http://svn.boost.org/trac/boost/changeset/69485

Log:
Enums: Added enum_array tests
Added:
   sandbox/enums/libs/enums/test/enum_array/cons/
   sandbox/enums/libs/enums/test/enum_array/cons/default.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/cons/initializer_list.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/data/
   sandbox/enums/libs/enums/test/enum_array/data/data.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/data/data_const.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/fill/
   sandbox/enums/libs/enums/test/enum_array/fill/fill.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/size/
   sandbox/enums/libs/enums/test/enum_array/size/size.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/special/
   sandbox/enums/libs/enums/test/enum_array/special/swap.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/swap/
   sandbox/enums/libs/enums/test/enum_array/swap/swap.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/types.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_array/version_pass.cpp (contents, props changed)
Text files modified:
   sandbox/enums/libs/enums/test/Jamfile.v2 | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: sandbox/enums/libs/enums/test/Jamfile.v2
==============================================================================
--- sandbox/enums/libs/enums/test/Jamfile.v2 (original)
+++ sandbox/enums/libs/enums/test/Jamfile.v2 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -58,6 +58,7 @@
 
    test-suite "enum_array"
         :
+ [ run enum_array/types.pass.cpp : : : : enum_array__types__pass ]
         [ run enum_array/cons/default.pass.cpp : : : : enum_array__cons__default__pass ]
         [ run enum_array/cons/initializer_list.pass.cpp : : : : enum_array__cons__initializer_list__pass ]
         [ run enum_array/size/size.pass.cpp : : : : enum_array__size__size__pass ]

Added: sandbox/enums/libs/enums/test/enum_array/cons/default.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/cons/default.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <boost/enums/enum_array.hpp>
+
+// enum_array();
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c;
+ BOOST_TEST(c.size() == 3);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/cons/initializer_list.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/cons/initializer_list.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <boost/enums/enum_array.hpp>
+
+// Construct with initizializer list
+
+#include "./Ex.hpp"
+#include <boost/enums/enum_array.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c = {{1, 2, 3.5}};
+ BOOST_TEST(c.size() == 3);
+ BOOST_TEST(c[EC3::Enum0] == 1);
+ BOOST_TEST(c[EC3::Enum1] == 2);
+ BOOST_TEST(c[EC3::Enum2] == 3.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/data/data.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/data/data.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+////////////////////////////////////////////////////////////////////////////////===----------------------------------------------------------------------===//
+//
+// 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>
+
+// T *data();
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c = {{1, 2, 3.5}};
+ T* p = c.data();
+ BOOST_TEST(p[0] == 1);
+ BOOST_TEST(p[1] == 2);
+ BOOST_TEST(p[2] == 3.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/data/data_const.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/data/data_const.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+////////////////////////////////////////////////////////////////////////////////===----------------------------------------------------------------------===//
+//
+// 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>
+
+// const T* data() const;
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ const C c = {{1, 2, 3.5}};
+ const T* p = c.data();
+ BOOST_TEST(p[0] == 1);
+ BOOST_TEST(p[1] == 2);
+ BOOST_TEST(p[2] == 3.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/fill/fill.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/fill/fill.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void fill(const T& u);
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c = {{1, 2, 3.5}}; c.fill(5.5);
+ BOOST_TEST(c.size() == 3);
+ BOOST_TEST(c[EC3::Enum0] == 5.5);
+ BOOST_TEST(c[EC3::Enum1] == 5.5);
+ BOOST_TEST(c[EC3::Enum2] == 5.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/size/size.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/size/size.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c = {{1, 2, 3.5}};
+ BOOST_TEST(c.size() == 3);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/special/swap.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/special/swap.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c1 = {{1, 2, 3.5}};
+ C c2 = {{4, 5, 6.5}};
+ swap(c1, c2);
+ BOOST_TEST(c1.size() == 3);
+ BOOST_TEST(c1[EC3::Enum0] == 4);
+ BOOST_TEST(c1[EC3::Enum1] == 5);
+ BOOST_TEST(c1[EC3::Enum2] == 6.5);
+ BOOST_TEST(c2.size() == 3);
+ BOOST_TEST(c2[EC3::Enum0] == 1);
+ BOOST_TEST(c2[EC3::Enum1] == 2);
+ BOOST_TEST(c2[EC3::Enum2] == 3.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/swap/swap.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/swap/swap.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+//////////////////////////////////////////////////////////////////////////////
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void swap(array& a);
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ C c1 = {{1, 2, 3.5}};
+ C c2 = {{4, 5, 6.5}};
+ c1.swap(c2);
+ BOOST_TEST(c1.size() == 3);
+ BOOST_TEST(c1[EC3::Enum0] == 4);
+ BOOST_TEST(c1[EC3::Enum1] == 5);
+ BOOST_TEST(c1[EC3::Enum2] == 6.5);
+ BOOST_TEST(c2.size() == 3);
+ BOOST_TEST(c2[EC3::Enum0] == 1);
+ BOOST_TEST(c2[EC3::Enum1] == 2);
+ BOOST_TEST(c2[EC3::Enum2] == 3.5);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_array/types.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/types.pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T, typename EC >
+// struct enum_array
+// {
+// // types:
+// typedef T& reference;
+// typedef const T& const_reference;
+// typedef implementation defined iterator;
+// typedef implementation defined const_iterator;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef boost::reverse_iterator<iterator> reverse_iterator;
+// typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#include <boost/enums/enum_array.hpp>
+#include "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+#include <iterator>
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef boost::enums::enum_array<T, EC3> C;
+ BOOST_STATIC_ASSERT((boost::is_same<C::reference, T&>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::const_reference, const T&>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::iterator, T*>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::const_iterator, const T*>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::pointer, T*>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::const_pointer, const T*>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::size_type, std::size_t>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::difference_type, std::ptrdiff_t>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value));
+ BOOST_STATIC_ASSERT((boost::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value));
+ }
+}

Added: sandbox/enums/libs/enums/test/enum_array/version_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_array/version_pass.cpp 2011-03-02 12:14:40 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+// Adapted from libcxx tests
+//
+////////////////////////////////////////////////////////////////////////////////===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <enum_array>
+
+#include <boost/enums/enum_array.hpp>
+
+#ifndef BOOST_ENUMS_VERSION
+#error BOOST_ENUMS_VERSION not defined
+#endif
+
+int main()
+{
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk