Revision 6213d97e gruel/src/lib/pmt/qa_pmt_prims.cc

b/gruel/src/lib/pmt/qa_pmt_prims.cc
23 23
#include <qa_pmt_prims.h>
24 24
#include <cppunit/TestAssert.h>
25 25
#include <gruel/msg_passing.h>
26
#include <stdio.h>
26
#include <cstdio>
27
#include <cstring>
27 28
#include <sstream>
28 29

29 30
using namespace pmt;
......
557 558
  CPPUNIT_ASSERT(!pmt_subsetp(l3,l2));
558 559
}
559 560

561
void
562
qa_pmt_prims::test_sugar()
563
{
564
  CPPUNIT_ASSERT(pmt_is_symbol(mp("my-symbol")));
565
  CPPUNIT_ASSERT_EQUAL((long) 10, pmt_to_long(mp(10)));
566
  CPPUNIT_ASSERT_EQUAL((double) 1e6, pmt_to_double(mp(1e6)));
567
  CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, 3),
568
		       pmt_to_complex(mp(std::complex<double>(2, 3))));
569

570
  int buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
571
  pmt_t blob = mp(buf, sizeof(buf));
572
  const void *data = pmt_blob_data(blob);
573
  size_t nbytes = pmt_blob_length(blob);
574
  CPPUNIT_ASSERT_EQUAL(sizeof(buf), nbytes);
575
  CPPUNIT_ASSERT(memcmp(buf, data, nbytes) == 0);
576
}

Also available in: Unified diff