本文整理汇总了C++中TestState类的典型用法代码示例。如果您正苦于以下问题:C++ TestState类的具体用法?C++ TestState怎么用?C++ TestState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestWriteMethod
void TestWriteMethod()
{
TestState* state = WriteNextStateStart();
state->Write();
state->Write();
state->Write();
WriteNextStateStop();
}
示例2: TestReadMethod
void TestReadMethod()
{
TestState* state;
int fCount = 0;
long result[SIZE];
UInt16 cur_index;
UInt16 next_index;
do {
cur_index = GetCurrentIndex();
fCount++;
state = ReadCurrentState();
bool res = state->ReadCopy(result);
next_index = GetCurrentIndex();
if (!res)
printf("TestReadMethod fCount %ld cur %ld next %ld\n", fCount, cur_index, next_index);
}while (cur_index != next_index);
state->Check(result);
}
示例3: check_localization_variable
void check_localization_variable( TestState& state ) {
dStorm::input::Traits<dStorm::Localization> traits;
dStorm::Localization loc;
loc.position_x() = 15 * boost::units::si::meter;
ValueVariable<localization::PositionX> v;
try {
v.get(traits);
state.fail( "No error thrown when traits with X coordinate unset were provided to get()" );
} catch (...) {}
DynamicUnit meter_only;
meter_only[ *UnitTable().find("m") ] = 1;
DynamicQuantity fifteen_meters( 15, meter_only );
traits.position_x().is_given = true;
state( v.is_static(traits) == false );
state( v.get(traits) != fifteen_meters );
state( v.get(loc) == fifteen_meters );
}
示例4: mem
// make sure when we delete a Buffer, *all* the allocated
// memory goes away. As the only way to do this is to examine
// the malloc buffers in the kernel, this will only work on
// POSIX conforming systems, and probabably only Linux & BSD.
void
test_destruct()
{
// these tests are bogus unless you have both mallinfo()
// and also have memory statistics gathering turned on.
#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
Memory mem(5);
mem.addStats(__LINE__); // take a sample
Buffer *buf1, *buf2;
mem.startCheckpoint();
buf1 = new Buffer(NETBUFSIZE);
delete buf1;
if (mem.endCheckpoint()) {
runtest.pass ("Buffer::~Buffer()");
} else {
runtest.fail ("Buffer::~Buffer()");
}
mem.startCheckpoint();
buf2 = new Buffer(124);
delete buf2;
if (mem.endCheckpoint()) {
runtest.pass ("Buffer::~Buffer(size_t)");
} else {
runtest.fail ("Buffer::~Buffer(size_t)");
}
#endif
}
示例5: memset
// Make sure we can read and write binary AMF strings
void
test_String(void)
{
AMF amf_obj;
int fd, ret;
char buf[AMF_VIDEO_PACKET_SIZE+1];
// First see if we can read strings. This file is produced by
// using a network packet sniffer, and should be binary correct.
memset(buf, 0, AMF_VIDEO_PACKET_SIZE+1);
fd = open("string1.amf", O_RDONLY);
ret = read(fd, buf, AMF_VIDEO_PACKET_SIZE);
close(fd);
char *str = amf_obj.extractString(buf);
if (strcmp(str, "connect") == 0) {
runtest.pass("Extracted \"connect\" string");
} else {
runtest.fail("Extracted \"connect\" string");
}
// Now make sure we can also create strings. We'll create the same
// string we just read, and make sure they match.
char *connect = "connect";
void *out = amf_obj.encodeElement(AMF::STRING, connect, strlen(connect));
if (memcmp(out, buf, 10) == 0) {
runtest.pass("Encoded \"connect\" string");
} else {
runtest.fail("Encoded \"connect\" string");
}
delete str;
}
示例6: Buffer
void
test_read(std::string &filespec)
{
GNASH_REPORT_FUNCTION;
struct stat st;
boost::shared_ptr<Buffer> hex1(new Buffer("00 bf 00 00 01 28 54 43 53 4f 00 04 00 00 00 00 00 08 73 65 74 74 69 6e 67 73 00 00 00 00 00 04 67 61 69 6e 00 40 49 00 00 00 00 00 00 00 00 0f 65 63 68 6f 73 75 70 70 72 65 73 73 69 6f 6e 01 00 00 00 11 64 65 66 61 75 6c 74 6d 69 63 72 6f 70 68 6f 6e 65 02 00 0e 2f 64 65 76 2f 69 6e 70 75 74 2f 6d 69 63 00 00 0d 64 65 66 61 75 6c 74 63 61 6d 65 72 61 02 00 00 00 00 0d 64 65 66 61 75 6c 74 6b 6c 69 6d 69 74 00 40 59 00 00 00 00 00 00 00 00 0d 64 65 66 61 75 6c 74 61 6c 77 61 79 73 01 00 00 00 10 63 72 6f 73 73 64 6f 6d 61 69 6e 41 6c 6c 6f 77 01 01 00 00 11 63 72 6f 73 73 64 6f 6d 61 69 6e 41 6c 77 61 79 73 01 01 00 00 18 61 6c 6c 6f 77 54 68 69 72 64 50 61 72 74 79 4c 53 4f 41 63 63 65 73 73 01 01 00 00 0c 74 72 75 73 74 65 64 50 61 74 68 73 03 00 00 09 00 00 0c 6c 6f 63 61 6c 53 65 63 50 61 74 68 02 00 00 00 00 10 6c 6f 63 61 6c 53 65 63 50 61 74 68 54 69 6d 65 00 42 71 6d 14 10 22 e0 00 00"));
if (stat(filespec.c_str(), &st) == 0) {
SOL sol;
sol.readFile(filespec);
vector<boost::shared_ptr<cygnal::Element> > els = sol.getElements();
if (els.size() > 1) {
string str = els[2]->to_string();
// Make sure multiple elements of varying datatypes are checked for.
if ((strcmp(els[0]->getName(), "gain") == 0) &&
(strcmp(els[2]->getName(), "defaultmicrophone") == 0) &&
(str == "/dev/input/mic") &&
(strcmp(els[5]->getName(), "defaultalways") == 0) &&
(strcmp(els[9]->getName(), "trustedPaths") == 0)) {
runtest.pass("Read SOL File");
} else {
runtest.fail("Read SOL file");
}
} else {
runtest.fail("Read SOL file");
}
// sol.dump();
}
}
示例7: a
//
// Machinery for delayed images rendering (e.g. Xv with YV12 or VAAPI)
//
void
test_iterators(Renderer *renderer, const std::string &type)
{
cout << "\t"<< type << " iterator tests" << endl;
if (!renderer) {
runtest.unresolved("No renderer to test!");
return;
}
Renderer::RenderImages::iterator fit = renderer->getFirstRenderImage();
Renderer::RenderImages::iterator lit = renderer->getLastRenderImage();
// When there are no images, the first and last are the same obviously
if (fit == lit) {
runtest.pass("getFirstRenderImage()");
} else {
runtest.fail("getFirstRenderImage()");
}
#if 0
geometry::Point2d a(1, 2);
geometry::Point2d c(3, 4);
Renderer::RenderImage image;
image::GnashImage *frame = new image::ImageRGBA(10, 10);
// gnash::GnashVaapiImage *foo = static_cast<gnash::GnashVaapiImage *>(frame);
// gnash::GnashVaapiImageProxy *bar = new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y);
std::auto_ptr<image::GnashImage> rgba(frame);
// image.reset(new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y));
renderer->addRenderImage(image);
// image.reset(new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y));
renderer->addRenderImage(image);
#endif
fit = renderer->getFirstRenderImage();
lit = renderer->getLastRenderImage();
// When there are no images, the first and last are the same obviously
if (fit != lit) {
runtest.pass("addRenderImage()");
} else {
runtest.fail("addRenderImage()");
}
#if 0
typedef boost::shared_ptr<GnashVaapiImageProxy> RenderImage;
typedef std::vector<RenderImage> RenderImages;
// Get first render image
virtual RenderImages::iterator getFirstRenderImage()
{ return _render_images.begin(); }
virtual RenderImages::const_iterator getFirstRenderImage() const
{ return _render_images.begin(); }
// Get last render image
virtual RenderImages::iterator getLastRenderImage()
{ return _render_images.end(); }
virtual RenderImages::const_iterator getLastRenderImage() const
{ return _render_images.end(); }
#endif
}
示例8:
void
test_bool(as_value boolval)
{
if (boolval.is_bool()) {
runtest.pass("as_value(bool)");
} else {
runtest.fail("as_value(bool)");
}
}
示例9: Element
void
test_data()
{
LcShm lcs;
// LcShm lcs=LcShm();
char *shmaddr;
const string con1 = "localhost:WeBuildTheseOOOOOOOOOOOOOOOOO";
if (lcs.connect(con1)) {
runtest.pass("LcShm::connect(localhost:lc_reply)");
} else {
runtest.fail("LcShm::connect(localhost:lc_reply)");
}
shmaddr = reinterpret_cast<char*>(lcs.begin()); // for gdb
Element *el;
vector<amf::Element *> els;
#if 0
// Apparently this constructor no longer exists.
el = new Element(true, 123.456, 987.654, "IAmReplyingNow");
// el->dump();
els.push_back(el);
delete el;
#endif
#if 0
//
el = new Element(true);
els.push_back(el);
el = new Element(12.34);
els.push_back(el);
el = new Element(12.34);
els.push_back(el);
string str = "IAmReplyingNow";
el = new Element(str);
els.push_back(el);
#endif
string str = "Volume Level 10 ";
el = new Element(str);
els.push_back(el);
// Send the AMF objects
const std::string localS="localhost";
lcs.send(con1, localS, els);
// system("ipcs");
// system("dumpshm -i");
sleep(3);
delete el;
}
示例10: pass
void
test_Boolean(void)
{
AMF amf_obj;
bool bo = false;
// Write a number element
void *out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
if (amf_obj.extractElementHeader(out) == AMF::BOOLEAN) {
runtest.pass("Boolean header correct");
} else {
runtest.fail("Boolean header not correct");
}
if (amf_obj.extractElementLength(out) == 1) {
runtest.pass("Boolean length returned correct");
} else {
runtest.fail("Boolean length returned not correct");
}
if (*((char *)out + 1) == 0) {
pass("Boolean false returned correct");
} else {
runtest.fail("Boolean false returned not correct");
}
bo = true;
out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
if (*((char *)out + 1) == 1) {
runtest.pass("Boolean true returned correct");
} else {
runtest.fail("Boolean true returned not correct");
}
}
示例11: open
int
main(int /*argc*/, char** /*argv*/)
{
const char* input = INPUT; // Should be the path to this file
const char* cachename = "NoSeekFileTestCache";
int fd = open(input, O_RDONLY);
int raw = open(input, O_RDONLY);
dup2(fd, 0);
gnash::IOChannel* reader = gnash::noseek_fd_adapter::make_stream(0, cachename);
assert(reader);
compare_reads(reader, raw, "wrapped", "raw");
lseek(raw, 0, SEEK_SET);
reader->seek(0);
compare_reads(reader, raw, "wrapped-rewind", "raw-rewind");
FILE* f = std::fopen(cachename, "r");
std::auto_ptr<gnash::IOChannel> orig = gnash::makeFileChannel(f, false);
lseek(raw, 0, SEEK_SET);
compare_reads(orig.get(), raw, "cache", "raw");
if (sizeof(size_t) != sizeof(std::streamoff)) {
std::streampos pos = std::numeric_limits<size_t>::max();
pos += orig->size() / 2;
// Check that seek() handles integer overflow situations gracefully.
if (orig->seek(pos)) {
runtest.fail("Successfully sought to an invalid position.");
} else {
runtest.pass("Gracefully handled invalid seek.");
}
}
return 0;
}
示例12:
// Each Renderer has an associated display device, currently EGL
// for OpenVG, OpenGLES1, and OpenGLES2. The DirectFB device is
// also available for these three renderers. The EGL device can
// also be run under X11 using the Mesa libraries. Both EGL and
// DirectFB are primarily for framebuffers. While all of the methods
// of each device class are available to the Renderer, most aren't
// exposed with more accesors beyond these for manipulating the
// device setting itself.
void
test_device(Renderer *renderer, const std::string &type)
{
cout << endl << "Testing " << type << " Device" << endl;
#if 0
boost::shared_array<renderer::GnashDevice::dtype_t> devs = renderer->probeDevices();
if (devs) {
runtest.pass("Renderer::probeDevices()");
} else {
runtest.fail("Renderer::probeDevices()");
}
// Be default, there should be no device associated with this
// renderer yet.
if (renderer->getDevice() == GnashDevice::NODEV) {
runtest.pass("Renderer::getDevice()");
} else {
runtest.fail("Renderer::getDevice()");
}
// Set to a device and see if it's axctually set
renderer->setDevice(GnashDevice::X11);
if (renderer->getDevice() == GnashDevice::X11) {
runtest.pass("Renderer::setDevice()");
} else {
runtest.fail("Renderer::setDevice()");
}
// reset to the original value so we don't screw up future tests
renderer->resetDevice();
#endif
}
示例13: exit
void
load_data()
{
LcShm lc;
char *shmaddr;
string con1 = "lc_reply";
if (!lc.connect(con1)) {
if (errno == EACCES) {
runtest.untested("Couldn't map input file, permission problems!!");
} else {
runtest.unresolved("LcShm::connect()");
}
exit(0);
}
shmaddr = reinterpret_cast<char*>(lc.begin());
// if (memcmp(shmaddr, con1.c_str():
// Since this is a test case, populate the memory with known good data
string srcdir = SRCDIR;
srcdir += "/segment.raw";
int fd = ::open(srcdir.c_str(), O_RDONLY);
void *dataptr = mmap(0, 64528, PROT_READ, MAP_SHARED, fd, 0);
if (dataptr != (void*)-1) {
memcpy(shmaddr, dataptr, 64528);
} else {
if (errno == EACCES) {
runtest.unresolved("Couldn't map input file, permission problems!!");
} else {
runtest.unresolved("Couldn't map input file!");
log_debug("Error was: %s", strerror(errno));
}
exit(0);
}
::close(fd);
}
示例14: memset
void
test_remove()
{
Network::byte_t *data1 = new Network::byte_t[20];
memset(data1, 0, 20);
Network::byte_t *data2 = new Network::byte_t[20];
memset(data2, 0, 20);
Network::byte_t *data3 = new Network::byte_t[20];
memset(data3, 0, 20);
// populate a buffer with some data
for (size_t i=0; i< 19; i++) {
data1[i] = i + 'a';
}
// Build identical buffer nissing one character
memcpy(data2, data1, 6);
memcpy(data2 + 6, data1 + 7, 20-7);
// Remove a single byte
Network::byte_t byte = 'g';
Buffer buf1(20);
buf1.clear();
buf1.copy(data1, 20);
buf1.remove(byte);
if (memcmp(data2, buf1.reference(), 19) == 0) {
runtest.pass ("Buffer::remove(Network::byte_t)");
} else {
runtest.fail ("Buffer::remove(Network::byte_t)");
}
Buffer buf2(20);
buf2.clear();
buf2.copy(data1, 20);
buf2.remove(6);
if (memcmp(data2, buf2.reference(), 18) == 0) {
runtest.pass ("Buffer::remove(int)");
} else {
runtest.fail ("Buffer::remove(int)");
}
// Remove a range of bytes
memcpy(data3, data1, 6);
memcpy(data3 + 6, data1 + 9, 1);
Buffer buf3(20);
buf3.clear();
buf3.copy(data1, 20);
buf3.remove(6, 8);
if (memcmp(data3, buf3.reference(), 6) == 0) {
runtest.pass ("Buffer::remove(int, int)");
} else {
runtest.fail ("Buffer::remove(int, int)");
}
delete[] data1;
delete[] data2;
delete[] data3;
}
示例15: ds
void
test_mem()
{
boost::shared_ptr<cygnal::Buffer> buf1(new cygnal::Buffer(12));
*buf1 = "Hello World";
// drop the null terminator byte we inherit when using a simnple
// string for testing
buf1->resize(buf1->size() - 1);
DiskStream ds("fooBar1", *buf1);
ds.writeToDisk();
ds.close();
struct stat st;
memset(&st, 0, sizeof(struct stat));
if (stat("fooBar1", &st) == 0) {
runtest.pass("DiskStream::writeToDisk()");
} else {
runtest.fail("DiskStream::writeToDisk()");
}
}