quint32 FadeChannel::address(const Doc* doc) const { if (fixture() == Fixture::invalidId()) return channel(); // No fixture, assume absolute DMX address Fixture* fxi = doc->fixture(fixture()); if (fxi == NULL) return QLCChannel::invalid(); else return (fxi->universeAddress() + channel()); }
static void test_config_file_read_invalid_values(void) { int ret = 0; struct configuration config; diag("Config file read invalid values"); ret = config_file_read(fixture("config2"), &config); ok(ret == -EINVAL && config.conf_file.tor_port == 0, "TorPort 65536 returns -EINVAL"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config3"), &config); ok(ret == -EINVAL && config.conf_file.tor_port == 0, "TorPort 0 returns -EINVAL"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config4"), &config); ok(ret == 0 && config.conf_file.tor_address == NULL, "TorAddress invalid IPv4 returns -1"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config5"), &config); ok(ret == 0 && config.conf_file.tor_address == NULL, "TorAddress invalid IPv6 returns -1"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config6"), &config); ok(ret == -EINVAL && config.conf_file.onion_mask == 0, "OnionAdrRange invalid range returns -EINVAL"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config7"), &config); ok(ret == -EINVAL && config.conf_file.onion_base == 0, "OnionAdrRange invalid IPv4 address returns -EINVAL"); memset(&config, 0x0, sizeof(config)); ret = config_file_read(fixture("config8"), &config); ok(ret == -EINVAL && config.conf_file.onion_base == 0, "OnionAdrRange invalid IPv6 address returns -EINVAL"); memset(&config, 0x0, sizeof(config)); #if (defined(__LP64__)) ret = config_file_read(fixture("config9_64"), &config); #else ret = config_file_read(fixture("config9_32"), &config); #endif ok(ret == -EINVAL && config.conf_file.onion_base == 0, "OnionAdrRange invalid mask returns -EINVAL"); }
bool FadeChannel::canFade(const Doc* doc) const { bool cFade = true; if (fixture() != Fixture::invalidId()) { Fixture* fxi = doc->fixture(fixture()); if (fxi != NULL) cFade = fxi->channelCanFade(channel()); } return cFade; }
TEST ( UnitTestCrackMesh , VerifyDestroy3D ) { // In 3D, build a 3x3x3 mesh each loop iteration, destroying a different // single element each time. stk::ParallelMachine pm = MPI_COMM_WORLD ; const int p_rank = stk::parallel_machine_rank( pm ); const unsigned nx = 3 , ny = 3 , nz = 3 ; for ( unsigned iz = 0 ; iz < nz ; ++iz ) { for ( unsigned iy = 0 ; iy < ny ; ++iy ) { for ( unsigned ix = 0 ; ix < nx ; ++ix ) { stk::mesh::fixtures::HexFixture fixture( pm , nx , ny , nz ); fixture.m_meta.commit(); fixture.generate_mesh(); fixture.m_bulk_data.modification_begin(); stk::mesh::Entity elem = fixture.elem( ix , iy , iz ); if ( fixture.m_bulk_data.is_valid(elem) && p_rank == fixture.m_bulk_data.parallel_owner_rank(elem) ) { stk::mesh::Entity tmp = elem ; fixture.m_bulk_data.destroy_entity( tmp ); } fixture.m_bulk_data.modification_end(); } } } }
void NetworkInterfaceASIOIntegrationFixture::assertCommandFailsOnClient( StringData db, const BSONObj& cmd, ErrorCodes::Error reason, Milliseconds timeoutMillis) { RemoteCommandRequest request{ fixture().getServers()[0], db.toString(), cmd, BSONObj(), nullptr, timeoutMillis}; auto res = runCommandSync(request); ASSERT_EQ(reason, res.status.code()); }
int Doc_Test::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: initTestCase(); break; case 1: defaults(); break; case 2: addFixture(); break; case 3: deleteFixture(); break; case 4: fixtureLimits(); break; case 5: fixture(); break; case 6: findAddress(); break; case 7: totalPowerConsumption(); break; case 8: addFunction(); break; case 9: deleteFunction(); break; case 10: function(); break; case 11: functionLimits(); break; case 12: load(); break; case 13: loadWrongRoot(); break; case 14: save(); break; default: ; } _id -= 15; } return _id; }
TEST(UnitTestGmeshFixture, testUnit) { const size_t num_x = 1; const size_t num_y = 2; const size_t num_z = 3; const size_t num_surf = 6; std::string config_mesh = Ioss::Utils::to_string(num_x) + "x" + Ioss::Utils::to_string(num_y) + "x" + Ioss::Utils::to_string(num_z) + "|sideset:xXyYzZ"; stk::io::util::Gmesh_STKmesh_Fixture fixture(MPI_COMM_WORLD, config_mesh); fixture.commit(); const std::vector<std::string> & sideset_names = fixture.getSidesetNames(); ASSERT_EQ( num_surf, sideset_names.size() ); for( size_t i = 0; i < num_surf; ++i ) { std::string surf_name = (std::string)"surface_" + Ioss::Utils::to_string(i+1); ASSERT_TRUE(surf_name == sideset_names[i]); } // Needed to test field data stk::mesh::Field<double,stk::mesh::Cartesian> * coord_field = fixture.getMetaData().get_field<stk::mesh::Field<double,stk::mesh::Cartesian> >(stk::topology::NODE_RANK, "coordinates"); ASSERT_TRUE( coord_field ); const stk::mesh::PartVector & side_parts = fixture.getSideParts(); ASSERT_EQ( sideset_names.size(), side_parts.size() ); }
void VCXYPad::removeFixture(quint32 fxi_id) { VCXYPadFixture fixture(m_doc); fixture.setFixture(fxi_id); m_fixtures.removeAll(fixture); }
void VCXYPadProperties::writeDMX(MasterTimer *timer, QList<Universe *> universes) { Q_UNUSED(timer); if (m_tab->currentIndex() != 2 || m_xyArea->hasPositionChanged() == false) return; //qDebug() << Q_FUNC_INFO; // This call also resets the m_changed flag in m_area QPointF pt = m_xyArea->position(); /* Scale XY coordinate values to 0.0 - 1.0 */ qreal x = SCALE(pt.x(), qreal(0), qreal(256), qreal(0), qreal(1)); qreal y = SCALE(pt.y(), qreal(0), qreal(256), qreal(0), qreal(1)); if (m_YInvertedRadio->isChecked()) y = qreal(1) - y; QTreeWidgetItemIterator it(m_tree); while (*it != NULL) { QVariant var((*it)->data(KColumnFixture, Qt::UserRole)); VCXYPadFixture fixture(m_doc, var); fixture.arm(); fixture.writeDMX(x, y, universes); fixture.disarm(); ++it; } }
void testfn_t::run() { if (before_) before_->run(); if (role_ == RTEST) { if (testrunner_t::current_->verbose_) fprintf(stderr, "Test %s:%s\n", suite(), name_); function_(); } else { int (*fixture)(void) = (int(*)(void))function_; if (testrunner_t::current_->verbose_) fprintf(stderr, "Fixture %s:%s\n", suite(), name_); if (fixture()) { fprintf(stderr, "%s:%s: fixture failed\n", suite(), name_); exit(1); } } if (after_) after_->run(); }
STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x1x1 ) { const size_t NX = 3; const size_t NY = 1; const size_t NZ = 1; stk::mesh::fixtures::HexFixture fixture(MPI_COMM_WORLD, NX, NY, NZ); fixture.m_fem_meta.commit(); fixture.generate_mesh(); { std::vector<size_t> counts ; stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); STKUNIT_EXPECT_EQ( counts[0] , 16u ); // nodes STKUNIT_EXPECT_EQ( counts[1] , 0u ); // edges STKUNIT_EXPECT_EQ( counts[2] , 0u ); // faces STKUNIT_EXPECT_EQ( counts[3] , 3u ); // elements } stk::mesh::PartVector empty_add_parts; stk::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts); { std::vector<size_t> counts ; stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); STKUNIT_EXPECT_EQ( counts[0] , 16u ); STKUNIT_EXPECT_EQ( counts[1] , 28u ); STKUNIT_EXPECT_EQ( counts[2] , 16u ); STKUNIT_EXPECT_EQ( counts[3] , 3u ); } }
extern void test_sagread_no_such_file(void) { sagread_t S; const char *path = fixture("no-such-file.sag"); CU_ASSERT_EQUAL_FATAL(sagread_open(path, &S), SAGREAD_ERROR); }
bool EFXFixture::saveXML(QDomDocument* doc, QDomElement* efx_root) const { QDomElement subtag; QDomElement tag; QDomText text; Q_ASSERT(doc != NULL); Q_ASSERT(efx_root != NULL); /* EFXFixture */ tag = doc->createElement(KXMLQLCEFXFixture); efx_root->appendChild(tag); /* Fixture ID */ subtag = doc->createElement(KXMLQLCEFXFixtureID); tag.appendChild(subtag); text = doc->createTextNode(QString("%1").arg(fixture())); subtag.appendChild(text); /* Direction */ subtag = doc->createElement(KXMLQLCEFXFixtureDirection); tag.appendChild(subtag); text = doc->createTextNode(Function::directionToString(m_direction)); subtag.appendChild(text); return true; }
extern void test_sagread_valid_fixture(void) { sagread_t S; const char *path = fixture("test.sag"); CU_ASSERT_EQUAL_FATAL(sagread_open(path, &S), SAGREAD_OK); CU_ASSERT_EQUAL_FATAL(S.grid.dim, 2); CU_ASSERT_EQUAL_FATAL(S.vector.dim, 2); int err; double x[2]; size_t n[2], lines = 0; do { err = sagread_line(S, n, x); switch (err) { case SAGREAD_OK: lines++; break; case SAGREAD_NODATA: case SAGREAD_EOF: break; default: CU_FAIL_FATAL("error from sagread_line"); }; } while (err != SAGREAD_EOF); CU_ASSERT_EQUAL(lines, 5); sagread_close(S); }
extern void test_svgread_fixtures(void) { size_t n = 1024; char buf[n]; const char* files[] = { "BrBG_10.svg", "eyes.svg", "french-flag.svg", "gradient-pastel-blue.svg", "Gradients_01.svg", "lemon-lime.svg", "mad-ids.svg", "punaisa_01.svg", "radial-eclipse.svg", "red-green-blue.svg", "subtle.svg" }; size_t i, nfile = sizeof(files)/sizeof(char*); for (i=0 ; i<nfile ; i++) { svg_list_t* svglist; CU_TEST_FATAL( (svglist = svg_list_new()) != NULL ); CU_TEST_FATAL( fixture(buf, n, "svg", files[i]) < n ); CU_ASSERT( svg_read(buf, svglist) == 0 ); CU_ASSERT( svg_list_size(svglist) > 0 ); svg_list_destroy(svglist); } }
// Save this function to an XML document bool Chaser::saveXML(QDomDocument* doc, QDomElement* wksp_root) { QDomElement root; QDomElement tag; QDomText text; QString str; int i = 0; Q_ASSERT(doc != NULL); Q_ASSERT(wksp_root != NULL); /* Function tag */ root = doc->createElement(KXMLQLCFunction); wksp_root->appendChild(root); root.setAttribute(KXMLQLCFunctionID, id()); root.setAttribute(KXMLQLCFunctionType, Function::typeToString(m_type)); root.setAttribute(KXMLQLCFunctionFixture, fixture()); root.setAttribute(KXMLQLCFunctionName, name()); /* Speed bus */ tag = doc->createElement(KXMLQLCBus); root.appendChild(tag); tag.setAttribute(KXMLQLCBusRole, KXMLQLCBusHold); str.setNum(busID()); text = doc->createTextNode(str); tag.appendChild(text); /* Direction */ tag = doc->createElement(KXMLQLCFunctionDirection); root.appendChild(tag); text = doc->createTextNode(Function::directionToString(m_direction)); tag.appendChild(text); /* Run order */ tag = doc->createElement(KXMLQLCFunctionRunOrder); root.appendChild(tag); text = doc->createTextNode(Function::runOrderToString(m_runOrder)); tag.appendChild(text); /* Steps */ QValueList <t_function_id>::iterator it; for (it = m_steps.begin(); it != m_steps.end(); ++it) { /* Step tag */ tag = doc->createElement(KXMLQLCFunctionStep); root.appendChild(tag); /* Step number */ tag.setAttribute(KXMLQLCFunctionNumber, i++); /* Step Function ID */ str.setNum(*it); text = doc->createTextNode(str); tag.appendChild(text); } return true; }
void VCXYPad::removeFixture(GroupHead const & head) { VCXYPadFixture fixture(m_doc); fixture.setHead(head); m_fixtures.removeAll(fixture); updateDegreesRange(); }
void NetworkInterfaceIntegrationFixture::assertCommandOK(StringData db, const BSONObj& cmd, Milliseconds timeoutMillis) { RemoteCommandRequest request{ fixture().getServers()[0], db.toString(), cmd, BSONObj(), nullptr, timeoutMillis}; auto res = runCommandSync(request); ASSERT_OK(res.status); ASSERT_OK(getStatusFromCommandResult(res.data)); ASSERT(!res.data["writeErrors"]); }
void NetworkInterfaceIntegrationFixture::assertCommandFailsOnServer(StringData db, const BSONObj& cmd, ErrorCodes::Error reason, Milliseconds timeoutMillis) { RemoteCommandRequest request{ fixture().getServers()[0], db.toString(), cmd, BSONObj(), nullptr, timeoutMillis}; auto res = runCommandSync(request); ASSERT_OK(res.status); auto serverStatus = getStatusFromCommandResult(res.data); ASSERT_EQ(reason, serverStatus); }
TEST(ThreadBehavior, StartCallsImplStart) { AutoPtr<PlatformFixture> fixture(new PlatformFixture); Thread t(MakeDelegate(&dummy)); // Expect that thread constructor won't call ThreadImpl::start EXPECT_TRUE(fixture->threadImpl->startCt == 0); t.start(); // Expect that Thread::start() will call ThreadImpl::start() EXPECT_TRUE(fixture->threadImpl->startCt == 1); }
void Doc::slotFixtureChanged(quint32 id) { /* Keep track of fixture addresses */ Fixture* fxi = fixture(id); for (uint i = fxi->universeAddress(); i < fxi->universeAddress() + fxi->channels(); i++) { m_addresses[i] = id; } setModified(); emit fixtureChanged(id); }
TEST(ThreadBehavior, StartOnce) { AutoPtr<PlatformFixture> fixture(new PlatformFixture); Thread::StartDelegate d(MakeDelegate(&dummy)); Thread t(d); fixture->threadImpl->startSuccess = Threading::Status_NoError; //, "Expected that Thread::start() would succeed if ThreadImpl::start succeds" EXPECT_TRUE(t.start() == Threading::Status_NoError); //, "Expected that Thread::start() would fail if called a second time" EXPECT_TRUE(t.start() == Threading::Status_Again); }
TEST(ThreadBehavior, ReturnCode) { AutoPtr<PlatformFixture> fixture(new PlatformFixture); Thread::StartDelegate d(MakeDelegate(&someFunc)); Thread t(d); fixture->threadImpl->startSuccess = Threading::Status_NoError; t.start(); fixture->threadImpl->run(); //, "Expected Thread::getReturnCode() would return the same value returned by the delegate" EXPECT_TRUE(t.getReturnCode() == MAGIC_NUMBER); }
TEST(ThreadBehavior, StartDelegate) { AutoPtr<PlatformFixture> fixture(new PlatformFixture); Thread::StartDelegate d(MakeDelegate(&someFunc)); Thread t(d); fixture->threadImpl->startSuccess = Threading::Status_NoError; t.start(); // "Expected that delegate passed to ThreadImpl::start would be same as delegate passed to Thread::Thread()" EXPECT_TRUE(fixture->threadImpl->param->d == MakeDelegate(&someFunc)); }
TEST(ThreadBehavior, StartParrotsImplStart) { AutoPtr<PlatformFixture> fixture(new PlatformFixture); Thread::StartDelegate d(MakeDelegate(&dummy)); Thread t(d); fixture->threadImpl->startSuccess = Threading::Status_PlatformError; //"Expected that Thread::start() would fail if ThreadImpl::start() fails"); EXPECT_TRUE(t.start() == Threading::Status_PlatformError); fixture->threadImpl->startSuccess = Threading::Status_NoError; //, "Expected that Thread::start() would succeed if ThreadImpl::start() succeeds"); EXPECT_TRUE(t.start() == Threading::Status_NoError); }
//---------------------------------------------------------------------------------------------- void TestFinderController::testFinderSelection() { TestFinderController fixture("Torrent", "DirectDownload"); // fixture._sut.addFinder(&fixture._finder1); fixture._sut.addFinder(&fixture._finder2); fixture.exercizeAndCheckFinderSelection(false, true, "Initial"); // fixture._sut.enable("DirectDownload", true); fixture.exercizeAndCheckFinderSelection(false, false, "Both active"); // fixture._sut.enable("Torrent", false); fixture.exercizeAndCheckFinderSelection(true, false, "DDL only"); }
QLCChannel::Group FadeChannel::group(const Doc* doc) const { uint chnum = QLCChannel::invalid(); Fixture* fxi = NULL; if (fixture() == Fixture::invalidId()) { // Do a reverse lookup; which fixture occupies channel() // which is now treated as an absolute DMX address. quint32 id = doc->fixtureForAddress(channel()); if (id == Fixture::invalidId()) return QLCChannel::Intensity; fxi = doc->fixture(id); if (fxi == NULL) return QLCChannel::Intensity; // Convert channel() to a relative channel number chnum = channel() - fxi->universeAddress(); } else { // This FadeChannel contains a valid fixture ID fxi = doc->fixture(fixture()); if (fxi == NULL) return QLCChannel::Intensity; // channel() is already a relative channel number chnum = channel(); } const QLCChannel* ch = fxi->channel(chnum); if (ch == NULL) return QLCChannel::Intensity; else return ch->group(); }
TEST( StkMeshIoBroker, active_only ) { // A simple test for reading and writing an exodus file using the StkMeshIoBroker. stk::ParallelMachine pm = MPI_COMM_WORLD; stk::io::StkMeshIoBroker fixture(pm); std::string input_base_filename = "unit_test.g"; bool ok = false; try { // Initialize meta data from exodus file fixture.add_mesh_database(input_base_filename, stk::io::READ_MESH); fixture.create_input_mesh(); ok = true; stk::mesh::MetaData & meta_data = fixture.meta_data(); // Add an "active" part... stk::mesh::Part &active = meta_data.declare_part("active", stk::topology::ELEMENT_RANK); meta_data.commit(); // bulk_data initialize (from exodus file) fixture.populate_bulk_data(); // Put some entities into the "active" part... // This will be used to test the I/O filtering via a selector... activate_entities(fixture, active); // exodus file creation std::string output_base_filename = "unit_test_output_filtered.e"; size_t index = fixture.create_output_mesh( output_base_filename, stk::io::WRITE_RESULTS ); // Set the output filter on the mesh_data... stk::mesh::Selector active_selector(active); fixture.set_subset_selector(index, active_selector); // process output const double time_step = 0; fixture.process_output_request(index, time_step); } catch(...) { ASSERT_TRUE(ok); } // Since correctness can only be established by running SEACAS tools, correctness // checking is left to the test XML. }
void NetworkInterfaceIntegrationFixture::assertWriteError(StringData db, const BSONObj& cmd, ErrorCodes::Error reason, Milliseconds timeoutMillis) { RemoteCommandRequest request{ fixture().getServers()[0], db.toString(), cmd, BSONObj(), nullptr, timeoutMillis}; auto res = runCommandSync(request); ASSERT_OK(res.status); ASSERT_OK(getStatusFromCommandResult(res.data)); ASSERT(res.data["writeErrors"]); auto firstWriteError = res.data["writeErrors"].embeddedObject().firstElement().embeddedObject(); Status writeErrorStatus(ErrorCodes::Error(firstWriteError.getIntField("code")), firstWriteError.getStringField("errmsg")); ASSERT_EQ(reason, writeErrorStatus); }
// // Allocate space for some run time stuff // void Scene::arm() { // Fetch the fixture address for run time access. // It cannot change when functions have been armed for running m_address = _app->doc()->fixture(fixture())->universeAddress(); if (m_runTimeData == NULL) m_runTimeData = new RunTimeData[m_channels]; if (m_channelData == NULL) m_channelData = new t_buffer_data[m_channels]; if (m_eventBuffer == NULL) m_eventBuffer = new EventBuffer(m_channels, KFrequency >> 1); }