[compute] 17/46: Add test for vector move ctor when custom allocator is used

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Dec 21 18:28:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository compute.

commit 01af4136da68d7ec31c58c25053de23c984b4db5
Author: Jakub Szuppe <j.szuppe at gmail.com>
Date:   Mon Oct 5 13:04:42 2015 +0200

    Add test for vector move ctor when custom allocator is used
---
 test/test_vector.cpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/test/test_vector.cpp b/test/test_vector.cpp
index 2f9bd00..7c88a56 100644
--- a/test/test_vector.cpp
+++ b/test/test_vector.cpp
@@ -19,6 +19,7 @@
 #include <boost/compute/algorithm/fill.hpp>
 #include <boost/compute/algorithm/find.hpp>
 #include <boost/compute/algorithm/remove.hpp>
+#include <boost/compute/allocator/pinned_allocator.hpp>
 #include <boost/compute/container/vector.hpp>
 
 #include "check_macros.hpp"
@@ -184,11 +185,27 @@ BOOST_AUTO_TEST_CASE(max_size)
 BOOST_AUTO_TEST_CASE(move_ctor)
 {
       int data[] = { 11, 12, 13, 14 };
-      bc::vector<int> a(data, data + 4);
+      bc::vector<int> a(data, data + 4, queue);
       BOOST_CHECK_EQUAL(a.size(), size_t(4));
       CHECK_RANGE_EQUAL(int, 4, a, (11, 12, 13, 14));
 
       bc::vector<int> b(std::move(a));
+      BOOST_CHECK(a.size() == 0);
+      BOOST_CHECK(a.get_buffer().get() == 0);
+      BOOST_CHECK_EQUAL(b.size(), size_t(4));
+      CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
+}
+
+BOOST_AUTO_TEST_CASE(move_ctor_custom_alloc)
+{
+      int data[] = { 11, 12, 13, 14 };
+      bc::vector<int, bc::pinned_allocator<int> > a(data, data + 4, queue);
+      BOOST_CHECK_EQUAL(a.size(), size_t(4));
+      CHECK_RANGE_EQUAL(int, 4, a, (11, 12, 13, 14));
+
+      bc::vector<int, bc::pinned_allocator<int> > b(std::move(a));
+      BOOST_CHECK(a.size() == 0);
+      BOOST_CHECK(a.get_buffer().get() == 0);
       BOOST_CHECK_EQUAL(b.size(), size_t(4));
       CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/compute.git



More information about the debian-science-commits mailing list