summaryrefslogtreecommitdiff
path: root/gruel/src/lib/pmt/qa_pmt_prims.cc
diff options
context:
space:
mode:
authorEric Blossom2009-08-14 18:53:35 -0700
committerEric Blossom2009-08-14 18:53:35 -0700
commit7ca21b2eb16ed1495001cdd62d58a9d51dd3f436 (patch)
tree8801914b2b02c52514fd469d6f290ae7b39046c6 /gruel/src/lib/pmt/qa_pmt_prims.cc
parent1181c2fe069075f9ceb3b66ed937115ff39aafa9 (diff)
downloadgnuradio-7ca21b2eb16ed1495001cdd62d58a9d51dd3f436.tar.gz
gnuradio-7ca21b2eb16ed1495001cdd62d58a9d51dd3f436.tar.bz2
gnuradio-7ca21b2eb16ed1495001cdd62d58a9d51dd3f436.zip
Added most of the support for a new PMT type: tuple.
More QA code coming soon.
Diffstat (limited to 'gruel/src/lib/pmt/qa_pmt_prims.cc')
-rw-r--r--gruel/src/lib/pmt/qa_pmt_prims.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc
index b81354721..d31e3fabf 100644
--- a/gruel/src/lib/pmt/qa_pmt_prims.cc
+++ b/gruel/src/lib/pmt/qa_pmt_prims.cc
@@ -193,6 +193,69 @@ qa_pmt_prims::test_vectors()
CPPUNIT_ASSERT_EQUAL(s0, pmt_vector_ref(v1, i));
}
+static void
+check_tuple(size_t len, const std::vector<pmt_t> &s, pmt_t t)
+{
+ CPPUNIT_ASSERT_EQUAL(true, pmt_is_tuple(t));
+ CPPUNIT_ASSERT_EQUAL(len, pmt_length(t));
+
+ for (size_t i = 0; i < len; i++)
+ CPPUNIT_ASSERT_EQUAL(s[i], pmt_tuple_ref(t, i));
+
+}
+
+void
+qa_pmt_prims::test_tuples()
+{
+ pmt_t t0 = pmt_make_tuple();
+ CPPUNIT_ASSERT_EQUAL(size_t(0), pmt_length(t0));
+
+ std::vector<pmt_t> s(10);
+ for (size_t i = 0; i < 10; i++){
+ std::ostringstream os;
+ os << "s" << i;
+ s[i] = pmt_string_to_symbol(os.str());
+ }
+
+ pmt_t t;
+
+ t = pmt_make_tuple();
+ check_tuple(0, s, t);
+
+ t = pmt_make_tuple(s[0]);
+ check_tuple(1, s, t);
+
+ t = pmt_make_tuple(s[0], s[1]);
+ check_tuple(2, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2]);
+ check_tuple(3, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3]);
+ check_tuple(4, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4]);
+ check_tuple(5, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5]);
+ check_tuple(6, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6]);
+ check_tuple(7, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
+ check_tuple(8, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8]);
+ check_tuple(9, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9]);
+ check_tuple(10, s, t);
+
+ t = pmt_make_tuple(s[0], s[1], s[2]);
+ CPPUNIT_ASSERT_THROW(pmt_tuple_ref(t, 3), pmt_out_of_range);
+}
+
void
qa_pmt_prims::test_equivalence()
{
@@ -436,3 +499,4 @@ qa_pmt_prims::test_sets()
CPPUNIT_ASSERT(!pmt_subsetp(l2,l1));
CPPUNIT_ASSERT(!pmt_subsetp(l3,l2));
}
+