[compute] 18/46: Add more test for vector with custom allocator

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 5e2598bfdd73f8c493035f08c93b468eab9fd4b8
Author: Jakub Szuppe <j.szuppe at gmail.com>
Date:   Mon Oct 5 13:25:25 2015 +0200

    Add more test for vector with custom allocator
---
 test/test_vector.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/test/test_vector.cpp b/test/test_vector.cpp
index 7c88a56..4cbe5e2 100644
--- a/test/test_vector.cpp
+++ b/test/test_vector.cpp
@@ -347,4 +347,92 @@ BOOST_AUTO_TEST_CASE(resize_throw_exception)
     CHECK_RANGE_EQUAL(int, 8, vec, (1, 2, 3, 4, 5, 6, 7, 8));
 }
 
+BOOST_AUTO_TEST_CASE(copy_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(a, queue);
+    BOOST_CHECK_EQUAL(b.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
+}
+
+BOOST_AUTO_TEST_CASE(copy_ctor_different_alloc)
+{
+    int data[] = { 11, 12, 13, 14 };
+    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, bc::pinned_allocator<int> > b(a, queue);
+    BOOST_CHECK_EQUAL(b.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
+
+    std::vector<int> host_vector;
+    host_vector.push_back(1);
+    host_vector.push_back(9);
+    host_vector.push_back(7);
+    host_vector.push_back(9);
+
+    bc::vector<int, bc::pinned_allocator<int> > c(host_vector, queue);
+    BOOST_CHECK_EQUAL(c.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, c, (1, 9, 7, 9));
+}
+
+BOOST_AUTO_TEST_CASE(assignment_operator)
+{
+    int adata[] = { 11, 12, 13, 14 };
+    bc::vector<int> a(adata, adata + 4, queue);
+    BOOST_CHECK_EQUAL(a.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, a, (11, 12, 13, 14));
+
+    bc::vector<int> b = a;
+    BOOST_CHECK_EQUAL(b.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
+
+    bc::vector<int, bc::pinned_allocator<int> > c = b;
+    BOOST_CHECK_EQUAL(c.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, c, (11, 12, 13, 14));
+
+    int ddata[] = { 21, 22, 23 };
+    bc::vector<int, bc::pinned_allocator<int> > d(ddata, ddata + 3, queue);
+    BOOST_CHECK_EQUAL(d.size(), size_t(3));
+    CHECK_RANGE_EQUAL(int, 3, d, (21, 22, 23));
+
+    a = d;
+    BOOST_CHECK_EQUAL(a.size(), size_t(3));
+    CHECK_RANGE_EQUAL(int, 3, a, (21, 22, 23));
+
+    std::vector<int> host_vector;
+    host_vector.push_back(1);
+    host_vector.push_back(9);
+    host_vector.push_back(7);
+    host_vector.push_back(9);
+
+    d = host_vector;
+    BOOST_CHECK_EQUAL(d.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, d, (1, 9, 7, 9));
+}
+
+BOOST_AUTO_TEST_CASE(swap_ctor_custom_alloc)
+{
+    int adata[] = { 11, 12, 13, 14 };
+    bc::vector<int, bc::pinned_allocator<int> > a(adata, adata + 4, queue);
+    BOOST_CHECK_EQUAL(a.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, a, (11, 12, 13, 14));
+
+    int bdata[] = { 21, 22, 23 };
+    bc::vector<int, bc::pinned_allocator<int> > b(bdata, bdata + 3, queue);
+    BOOST_CHECK_EQUAL(b.size(), size_t(3));
+    CHECK_RANGE_EQUAL(int, 3, b, (21, 22, 23));
+
+    a.swap(b);
+    BOOST_CHECK_EQUAL(a.size(), size_t(3));
+    CHECK_RANGE_EQUAL(int, 3, a, (21, 22, 23));
+    BOOST_CHECK_EQUAL(b.size(), size_t(4));
+    CHECK_RANGE_EQUAL(int, 4, b, (11, 12, 13, 14));
+}
+
 BOOST_AUTO_TEST_SUITE_END()

-- 
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