本文整理汇总了C++中TEST_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_ASSERT函数的具体用法?C++ TEST_ASSERT怎么用?C++ TEST_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_0004_conf
int main_0004_conf (int argc, char **argv) {
rd_kafka_t *rk;
rd_kafka_topic_t *rkt;
rd_kafka_conf_t *ignore_conf, *conf, *conf2;
rd_kafka_topic_conf_t *ignore_topic_conf, *tconf, *tconf2;
char errstr[512];
const char **arr_orig, **arr_dup;
size_t cnt_orig, cnt_dup;
int i;
const char *topic;
static const char *gconfs[] = {
"message.max.bytes", "12345", /* int property */
"client.id", "my id", /* string property */
"debug", "topic,metadata,interceptor", /* S2F property */
"topic.blacklist", "__.*", /* #778 */
"auto.offset.reset", "earliest", /* Global->Topic fallthru */
#if WITH_ZLIB
"compression.codec", "gzip", /* S2I property */
#endif
NULL
};
static const char *tconfs[] = {
"request.required.acks", "-1", /* int */
"auto.commit.enable", "false", /* bool */
"auto.offset.reset", "error", /* S2I */
"offset.store.path", "my/path", /* string */
NULL
};
test_conf_init(&ignore_conf, &ignore_topic_conf, 10);
rd_kafka_conf_destroy(ignore_conf);
rd_kafka_topic_conf_destroy(ignore_topic_conf);
topic = test_mk_topic_name("0004", 0);
/* Set up a global config object */
conf = rd_kafka_conf_new();
for (i = 0 ; gconfs[i] ; i += 2) {
if (rd_kafka_conf_set(conf, gconfs[i], gconfs[i+1],
errstr, sizeof(errstr)) !=
RD_KAFKA_CONF_OK)
TEST_FAIL("%s\n", errstr);
}
rd_kafka_conf_set_dr_cb(conf, dr_cb);
rd_kafka_conf_set_error_cb(conf, error_cb);
/* interceptor configs are not exposed as strings or in dumps
* so the dump verification step will not cover them, but valgrind
* will help track down memory leaks/use-after-free etc. */
rd_kafka_conf_interceptor_add_on_new(conf, "testic", my_on_new, NULL);
/* Set up a topic config object */
tconf = rd_kafka_topic_conf_new();
rd_kafka_topic_conf_set_partitioner_cb(tconf, partitioner);
rd_kafka_topic_conf_set_opaque(tconf, (void *)0xbeef);
for (i = 0 ; tconfs[i] ; i += 2) {
if (rd_kafka_topic_conf_set(tconf, tconfs[i], tconfs[i+1],
errstr, sizeof(errstr)) !=
RD_KAFKA_CONF_OK)
TEST_FAIL("%s\n", errstr);
}
/* Verify global config */
arr_orig = rd_kafka_conf_dump(conf, &cnt_orig);
conf_verify(__LINE__, arr_orig, cnt_orig, gconfs);
/* Verify copied global config */
conf2 = rd_kafka_conf_dup(conf);
arr_dup = rd_kafka_conf_dump(conf2, &cnt_dup);
conf_verify(__LINE__, arr_dup, cnt_dup, gconfs);
conf_cmp("global", arr_orig, cnt_orig, arr_dup, cnt_dup);
rd_kafka_conf_dump_free(arr_orig, cnt_orig);
rd_kafka_conf_dump_free(arr_dup, cnt_dup);
/* Verify topic config */
arr_orig = rd_kafka_topic_conf_dump(tconf, &cnt_orig);
conf_verify(__LINE__, arr_orig, cnt_orig, tconfs);
/* Verify copied topic config */
tconf2 = rd_kafka_topic_conf_dup(tconf);
arr_dup = rd_kafka_topic_conf_dump(tconf2, &cnt_dup);
conf_verify(__LINE__, arr_dup, cnt_dup, tconfs);
conf_cmp("topic", arr_orig, cnt_orig, arr_dup, cnt_dup);
rd_kafka_conf_dump_free(arr_orig, cnt_orig);
rd_kafka_conf_dump_free(arr_dup, cnt_dup);
/*
* Create kafka instances using original and copied confs
*/
/* original */
TEST_ASSERT(on_new_call_cnt == 0, "expected 0 on_new call, not %d",
on_new_call_cnt);
on_new_call_cnt = 0;
rk = test_create_handle(RD_KAFKA_PRODUCER, conf);
//.........这里部分代码省略.........
示例2: testTrue
void testTrue(void)
{
TEST_ASSERT(1);
TEST_ASSERT_TRUE(1);
}
示例3: StartThread
static void StartThread( void* arg )
{
KMutex locks[NESTING_DEPTH - 1];
DonorThreadParams donorParams[ NESTING_DEPTH ];
TestData* pTestData = ( TestData* ) arg;
for (uint32_t i = 0; i < NESTING_DEPTH - 1; i++) {
char tmp[30];
bool workerMutexCreateResult = false;
sprintf_s( tmp, sizeof(tmp), "Mutex %d", i );
workerMutexCreateResult = KMutexCreate( &locks[ i ], tmp );
}
KMutexLock( &locks[0], WAIT_FOREVER );
ConsoleLogLine( "%s got lock, My Priority: %d", s_data.threads[0].threadName,
KThreadGetPriority( &pTestData->threads[ 0 ] ) );
for ( uint32_t i = 1; i < NESTING_DEPTH; i++)
{
char name[16];
int thread_priority;
snprintf (name, sizeof name, "thread %d", i);
thread_priority = PRI_MIN + i * 3;
donorParams[ i ].lockPair.first = i < NESTING_DEPTH - 1 ? locks + i : NULL;
donorParams[ i ].lockPair.second = locks + i - 1;
donorParams[ i ].i = i;
donorParams[ i ].pThread = &pTestData->threads[ i ];
donorParams[ i ].pTestData = pTestData;
KThreadCreateParams params = {
.fn = DonorThreadFunction,
.pStack = pTestData->stacks[ i ],
.pThreadName = name,
.stackSizeInBytes = sizeof( pTestData->stacks[ i ] ),
.threadArg = &donorParams[i],
.threadPriority = thread_priority
};
ConsoleLogLine( "Starting %s with priority: %d", name, thread_priority );
TEST_ASSERT( KThreadCreate( &pTestData->threads[ i ], ¶ms ) );
/*
ConsoleLogLine ("%s should have priority %d. Actual priority: %d.",
name, thread_priority, KThreadGetPriority( &pTestData->threads[ i ] ) );
snprintf (name, sizeof name, "interloper %d", i);
interloperParams[ i ].i = i;
interloperParams[ i ].pThread = &pTestData->interloperThreads[ i ];
interloperParams[ i ].pTestData = pTestData;
KThreadCreateParams paramsInterloper = {
.fn = InterloperThreadFunction,
.pStack = pTestData->interloperStacks[ i ],
.pThreadName = name,
.stackSizeInBytes = sizeof( pTestData->interloperStacks[ i ] ),
.threadArg = &interloperParams[ i ],
.threadPriority = thread_priority - 1,
};
TEST_ASSERT( KThreadCreate( &pTestData->interloperThreads[ i ], ¶msInterloper ) );
*/
}
TEST_ASSERT_EQUAL_INT( NESTING_DEPTH - 1, pTestData->currentThreadIndexToRelease );
KMutexUnlock( &locks[ 0 ] );
/*
ConsoleLogLine("%s finishing with priority %d.\n", KThreadGetName( &pTestData->threads[ 0 ] ),
KThreadGetPriority( &pTestData->threads[ 0 ] ) );
*/
TEST_ASSERT( KThreadJoin( &pTestData->threads[ 1 ] ) && KThreadJoin( &pTestData->interloperThreads[ 1 ] ) );
}
static void TestPriorityDonateChain( void )
{
TestData* pTestData = &s_data;
pTestData->currentThreadIndexToRelease = 0;
KThreadCreateParams startThread = {
.fn = StartThread,
.pStack = pTestData->stacks[ 0 ],
.pThreadName = "StartThread",
.stackSizeInBytes = THREAD_STACK_SIZE,
.threadArg = pTestData,
.threadPriority = PRI_MIN,
};
pTestData->currentThreadIndexToRelease = 0;
bool startThreadCreateResult = KThreadCreate( &pTestData->threads[ 0 ], &startThread );
TEST_ASSERT( startThreadCreateResult );
//Test ends when StartThread Ends
bool waitForStartThreadEnd = KThreadJoin( &pTestData->threads[ 0 ] );
TEST_ASSERT( waitForStartThreadEnd );
}
static void
DonorThreadFunction( void *args )
{
DonorThreadParams* pParams = ( DonorThreadParams* )args;
if (pParams->lockPair.first)
KMutexLock(pParams->lockPair.first, WAIT_FOREVER );
ConsoleLogLine( "%s priority %d, Actual priority: %d\n",
KThreadGetName( pParams->pThread ), KThreadGetPriority( pParams->pThread ) );
TEST_ASSERT_EQUAL_INT( pParams->i - 1, pParams->pTestData->currentThreadIndexToRelease );
pParams->pTestData->currentThreadIndexToRelease = pParams->i;
KMutexLock(pParams->lockPair.second, WAIT_FOREVER );
TEST_ASSERT_EQUAL_INT( NESTING_DEPTH - pParams->i, pParams->pTestData->currentThreadIndexToRelease );
pParams->pTestData->currentThreadIndexToRelease = NESTING_DEPTH - ( pParams->i + 1 );
//.........这里部分代码省略.........
示例4: t0
void t0()
{
// ecst::fixed_set<100> ss;
vrm::core::fixed_vector_sparse_set<unsigned int, 100> ss;
TEST_ASSERT(ss.empty());
TEST_ASSERT_OP(ss.size(), ==, 0);
TEST_ASSERT(ss.add(0) == true);
TEST_ASSERT(ss.add(0) == false);
TEST_ASSERT(ss.add(0) == false);
TEST_ASSERT(!ss.empty());
TEST_ASSERT_OP(ss.size(), ==, 1);
TEST_ASSERT(ss.has(0));
TEST_ASSERT(!ss.has(1));
TEST_ASSERT(!ss.has(2));
TEST_ASSERT(ss.add(1) == true);
TEST_ASSERT(ss.add(1) == false);
TEST_ASSERT(!ss.empty());
TEST_ASSERT_OP(ss.size(), ==, 2);
TEST_ASSERT(ss.has(0));
TEST_ASSERT(ss.has(1));
TEST_ASSERT(!ss.has(2));
TEST_ASSERT(ss.add(2) == true);
TEST_ASSERT(ss.add(2) == false);
TEST_ASSERT(!ss.empty());
TEST_ASSERT_OP(ss.size(), ==, 3);
TEST_ASSERT(ss.has(0));
TEST_ASSERT(ss.has(1));
TEST_ASSERT(ss.has(2));
}
示例5: test_main
int test_main(int, char **)
{
typedef ion::playlists < ion::flat_playlist > playlists_t;
typedef ion::filter_playlist < playlists_t > filter_playlist_t;
ion::flat_playlist::unique_ids_t unique_ids_;
ion::flat_playlist *playlist1 = new ion::flat_playlist(unique_ids_);
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar11"), *ion::parse_metadata("{ \"title\" : \"hello 441\" }"), false), false);
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar12"), *ion::parse_metadata("{ \"title\" : \"abc def\" }"), false), false);
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar13"), *ion::parse_metadata("{ \"title\" : \"lorem ipsum\" }"), false), false);
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar14"), *ion::parse_metadata("{ \"title\" : \"max mustermann\" }"), false), false);
ion::flat_playlist *playlist2 = new ion::flat_playlist(unique_ids_);
playlist2->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar21"), *ion::parse_metadata("{ \"title\" : \"ugauga\" }"), false), false);
playlist2->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar22"), *ion::parse_metadata("{ \"title\" : \"john smith\" }"), false), false);
playlist2->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar23"), *ion::parse_metadata("{ \"title\" : \"test c55\" }"), false), false);
playlist2->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://bar24"), *ion::parse_metadata("{ \"title\" : \"xxycz\" }"), false), false);
playlists_t playlists;
playlists.add_playlist(playlists_t::playlist_ptr_t(playlist1));
playlists.add_playlist(playlists_t::playlist_ptr_t(playlist2));
filter_playlist_t filter_playlist(playlists, boost::phoenix::bind(&match, boost::phoenix::arg_names::arg1));
TEST_VALUE(ion::get_num_entries(filter_playlist), 3);
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 0)).get_path(), "bar12");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 1)).get_path(), "bar23");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 2)).get_path(), "bar24");
{
// testing uri-based retrieval and incompatibility marking
// since the playlist adds an id option to the URI, it is retrieved from one of the entries instead of created manually
ion::uri test_uri = boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 1));
TEST_ASSERT(ion::get_metadata_for(filter_playlist, test_uri), "");
ion::mark_backend_resource_incompatibility(filter_playlist, test_uri, "test_backend");
TEST_VALUE(boost::fusion::at_c < 2 > (*ion::get_entry(filter_playlist, 1)), true);
}
// The following code tests the signal relay in filter_playlist
// Internally, if one of the playlists that have URIs in the filter playlist proxy entry list get altered,
// the filter playlist is notified, and changes its proxy entry list accordingly.
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://extra"), *ion::parse_metadata("{ \"title\" : \"ccccc\" }"), false), true);
TEST_VALUE(ion::get_num_entries(filter_playlist), 4);
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 0)).get_path(), "bar12");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 1)).get_path(), "extra");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 2)).get_path(), "bar23");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 3)).get_path(), "bar24");
playlist2->remove_entry(*ion::get_entry(filter_playlist, 2), true);
//print_playlist(filter_playlist);
TEST_VALUE(ion::get_num_entries(filter_playlist), 3);
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 0)).get_path(), "bar12");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 1)).get_path(), "extra");
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 2)).get_path(), "bar24");
playlists.remove_playlist(*playlist1);
TEST_VALUE(ion::get_num_entries(filter_playlist), 1);
TEST_VALUE(boost::fusion::at_c < 0 > (*ion::get_entry(filter_playlist, 0)).get_path(), "bar24");
{
// The following code tests correct signal disconnection
playlists_t playlists_;
ion::flat_playlist *playlist1 = new ion::flat_playlist(unique_ids_);
filter_playlist_t *filter_playlist_ = new filter_playlist_t(playlists_, boost::phoenix::bind(&match, boost::phoenix::arg_names::arg1));
playlists_.add_playlist(playlists_t::playlist_ptr_t(playlist1));
delete filter_playlist_;
playlist1->add_entry(ion::flat_playlist::entry_t(ion::uri("foo://abc"), *ion::parse_metadata("{ \"title\" : \"ccccc\" }"), false), true);
}
return 0;
}
示例6: TEUCHOS_UNIT_TEST
//---------------------------------------------------------------------------//
TEUCHOS_UNIT_TEST( DomainTransporter, Cutoff )
{
typedef Tpetra::Vector<double,int,long> VectorType;
typedef MCLS::VectorTraits<VectorType> VT;
typedef Tpetra::CrsMatrix<double,int,long> MatrixType;
typedef MCLS::MatrixTraits<VectorType,MatrixType> MT;
typedef MCLS::AdjointHistory<long> HistoryType;
typedef std::mt19937 rng_type;
typedef MCLS::AdjointTally<VectorType> TallyType;
typedef MCLS::AlmostOptimalDomain<VectorType,MatrixType,rng_type,TallyType>
DomainType;
Teuchos::RCP<const Teuchos::Comm<int> > comm =
Teuchos::DefaultComm<int>::getComm();
int comm_size = comm->getSize();
int comm_rank = comm->getRank();
int local_num_rows = 10;
int global_num_rows = local_num_rows*comm_size;
Teuchos::RCP<const Tpetra::Map<int,long> > map =
Tpetra::createUniformContigMap<int,long>( global_num_rows, comm );
// Build the linear operator and solution vector.
Teuchos::RCP<MatrixType> A = Tpetra::createCrsMatrix<double,int,long>( map );
Teuchos::Array<long> global_columns( 1 );
Teuchos::Array<double> values( 1, 0.5 );
for ( int i = 0; i < global_num_rows; ++i )
{
if ( i >= local_num_rows*comm_rank && i < local_num_rows*(comm_rank+1) )
{
global_columns[0] = i;
A->insertGlobalValues( i, global_columns(), values() );
}
}
A->fillComplete();
Teuchos::RCP<VectorType> x = MT::cloneVectorFromMatrixRows( *A );
Teuchos::RCP<MatrixType> A_T = MT::copyTranspose(*A);
// Build the adjoint domain.
Teuchos::ParameterList plist;
plist.set<int>( "History Length", 1 );
Teuchos::RCP<DomainType> domain = Teuchos::rcp( new DomainType( A_T, x, plist ) );
Teuchos::RCP<MCLS::PRNG<rng_type> > rng = Teuchos::rcp(
new MCLS::PRNG<rng_type>( comm->getRank() ) );
domain->setRNG( rng );
// Build the domain transporter.
double weight = 3.0;
MCLS::DomainTransporter<DomainType> transporter( domain );
// Transport histories through the domain.
for ( int i = 0; i < global_num_rows; ++i )
{
if ( i >= local_num_rows*comm_rank && i < local_num_rows*(comm_rank+1) )
{
HistoryType history( i, i, weight );
history.live();
transporter.transport( history );
TEST_EQUALITY( history.globalState(), i );
TEST_EQUALITY( history.localState(), i - local_num_rows*comm_rank );
TEST_EQUALITY( history.weight(), weight / 2 );
TEST_EQUALITY( history.event(), MCLS::Event::CUTOFF );
TEST_ASSERT( !history.alive() );
}
}
// Check the tally.
Teuchos::ArrayRCP<const double> x_view = VT::view( *x );
double x_val = weight;
for ( int i = 0; i < local_num_rows; ++i )
{
TEST_EQUALITY( x_view[i], x_val );
}
}
示例7: TEUCHOS_UNIT_TEST
//---------------------------------------------------------------------------//
TEUCHOS_UNIT_TEST( DomainTransporter, Cutoff2 )
{
typedef Epetra_Vector VectorType;
typedef MCLS::VectorTraits<VectorType> VT;
typedef Epetra_RowMatrix MatrixType;
typedef MCLS::MatrixTraits<VectorType,MatrixType> MT;
typedef MCLS::AdjointHistory<int> HistoryType;
typedef std::mt19937 rng_type;
typedef MCLS::AdjointDomain<VectorType,MatrixType,rng_type> DomainType;
Teuchos::RCP<const Teuchos::Comm<int> > comm =
Teuchos::DefaultComm<int>::getComm();
Teuchos::RCP<Epetra_Comm> epetra_comm = getEpetraComm( comm );
int comm_size = comm->getSize();
int comm_rank = comm->getRank();
int local_num_rows = 10;
int global_num_rows = local_num_rows*comm_size;
Teuchos::RCP<Epetra_Map> map = Teuchos::rcp(
new Epetra_Map( global_num_rows, 0, *epetra_comm ) );
// Build the linear operator and solution vector.
Teuchos::RCP<Epetra_CrsMatrix> A =
Teuchos::rcp( new Epetra_CrsMatrix( Copy, *map, 0 ) );
Teuchos::Array<int> global_columns( 1 );
Teuchos::Array<double> values( 1 );
for ( int i = 1; i < global_num_rows; ++i )
{
global_columns[0] = i-1;
values[0] = -0.5;
A->InsertGlobalValues( i, global_columns().size(),
&values[0], &global_columns[0] );
}
global_columns[0] = global_num_rows-1;
values[0] = -0.5;
A->InsertGlobalValues( global_num_rows-1, global_columns.size(),
&values[0], &global_columns[0] );
A->FillComplete();
Teuchos::RCP<MatrixType> B = MT::copyTranspose(*A);
Teuchos::RCP<VectorType> x = MT::cloneVectorFromMatrixRows( *A );
// Build the adjoint domain.
Teuchos::ParameterList plist;
plist.set<int>( "Overlap Size", 2 );
Teuchos::RCP<DomainType> domain = Teuchos::rcp( new DomainType( B, x, plist ) );
Teuchos::RCP<MCLS::PRNG<rng_type> > rng = Teuchos::rcp(
new MCLS::PRNG<rng_type>( comm->getRank() ) );
domain->setRNG( rng );
// Build the domain transporter.
double weight = 3.0;
double relative_cutoff = weight / 4 + 0.01;
MCLS::DomainTransporter<DomainType> transporter( domain, plist );
domain->setCutoff( relative_cutoff );
// Transport histories through the domain.
for ( int i = 0; i < global_num_rows-2; ++i )
{
if ( comm_rank == comm_size - 1 )
{
if ( i >= local_num_rows*comm_rank && i < local_num_rows*(comm_rank+1) )
{
HistoryType history( i, i, weight );
history.live();
transporter.transport( history );
TEST_EQUALITY( history.globalState(), i+2 );
TEST_EQUALITY( history.weight(), weight / 4 );
TEST_EQUALITY( history.event(), MCLS::Event::CUTOFF );
TEST_ASSERT( !history.alive() );
}
}
else
{
if ( i >= local_num_rows*comm_rank && i < 1+local_num_rows*(comm_rank+1) )
{
HistoryType history( i, i, weight );
history.live();
transporter.transport( history );
TEST_EQUALITY( history.globalState(), i+2 );
TEST_EQUALITY( history.weight(), weight / 4 );
TEST_EQUALITY( history.event(), MCLS::Event::CUTOFF );
TEST_ASSERT( !history.alive() );
}
}
}
// Check the tally.
domain->domainTally()->combineSetTallies( comm );
Teuchos::ArrayRCP<const double> x_view =
VT::view( *x );
double x_val = weight;
for ( int i = 0; i < local_num_rows; ++i )
{
if ( comm_rank == comm_size-1 && i == local_num_rows-1 )
{
//.........这里部分代码省略.........
示例8: main
int main(int n, char **p)
{
Step::RefPtr<ifc2x3::ExpressDataSet> eds ;
try
{
std::cout << "Creating ExpressDataSet" << std::endl;
eds = new ifc2x3::ExpressDataSet;
}
catch (const std::exception& e)
{
TEST_FAILURE((std::string("Exception : ") + e.what()).c_str());
}
TEST_VALIDITY(eds);
LOG_DEBUG(std::endl << "Test with no Scale" << std::endl);
Step::RefPtr<ifc2x3::IfcCartesianTransformationOperator2DnonUniform> CTOperator2DnonUniform1 = eds->createIfcCartesianTransformationOperator2DnonUniform();
TEST_VALIDITY(CTOperator2DnonUniform1);
Step::RefPtr< ifc2x3::IfcDirection > Axis11 = eds->createIfcDirection();
ifc2x3::List_Real_2_3 ListReal11;
ListReal11.push_back(1.0);
ListReal11.push_back(0.0);
Axis11->setDirectionRatios(ListReal11);
CTOperator2DnonUniform1->setAxis1(Axis11);
Step::RefPtr< ifc2x3::IfcDirection > Axis21 = eds->createIfcDirection();
ifc2x3::List_Real_2_3 ListReal21;
ListReal21.push_back(0.0);
ListReal21.push_back(1.0);
Axis21->setDirectionRatios(ListReal21);
CTOperator2DnonUniform1->setAxis2(Axis21);
LOG_DEBUG("getScale2 = "<< Step::isUnset( CTOperator2DnonUniform1->getScale2()) << std::endl);
TEST_ASSERT(Step::isUnset( CTOperator2DnonUniform1->getScale2()));
LOG_DEBUG("getScl2 = "<< CTOperator2DnonUniform1->getScl2() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform1->getScl2()==1.0);
LOG_DEBUG("getScl = "<< CTOperator2DnonUniform1->getScl() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform1->getScl()==1.0);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
LOG_DEBUG(std::endl << "Test with CTOperator2DnonUniform2->setScale(2.5);" << std::endl);
Step::RefPtr<ifc2x3::IfcCartesianTransformationOperator2DnonUniform> CTOperator2DnonUniform2 = eds->createIfcCartesianTransformationOperator2DnonUniform();
TEST_VALIDITY(CTOperator2DnonUniform2);
Step::RefPtr< ifc2x3::IfcDirection > Axis12 = eds->createIfcDirection();
ifc2x3::List_Real_2_3 ListReal12;
ListReal12.push_back(2.0);
ListReal12.push_back(1.0);
Axis12->setDirectionRatios(ListReal12);
CTOperator2DnonUniform2->setAxis1(Axis12);
Step::RefPtr< ifc2x3::IfcDirection > Axis22 = eds->createIfcDirection();
ifc2x3::List_Real_2_3 ListReal22;
ListReal22.push_back(4.0);
ListReal22.push_back(1.0);
Axis22->setDirectionRatios(ListReal22);
CTOperator2DnonUniform2->setAxis2(Axis22);
CTOperator2DnonUniform2->setScale(2.5);
LOG_DEBUG("getScale2 = "<< Step::isUnset( CTOperator2DnonUniform2->getScale2()) << std::endl);
TEST_ASSERT(Step::isUnset( CTOperator2DnonUniform2->getScale2()));
LOG_DEBUG("getScl2 = "<< CTOperator2DnonUniform2->getScl2() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform2->getScl2()==2.5);
LOG_DEBUG("getScl = "<< CTOperator2DnonUniform2->getScl() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform2->getScl()==2.5);
CTOperator2DnonUniform2->setScale2(4.5);
LOG_DEBUG(std::endl << "Test with CTOperator2DnonUniform2->setScale2(4.5);" << std::endl);
LOG_DEBUG("getScale2 = "<< CTOperator2DnonUniform2->getScale2() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform2->getScale2()==4.5);
LOG_DEBUG("getScl2 = "<< CTOperator2DnonUniform2->getScl2() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform2->getScl2()==4.5);
LOG_DEBUG("getScl = "<< CTOperator2DnonUniform2->getScl() << std::endl);
TEST_ASSERT(CTOperator2DnonUniform2->getScl()==2.5);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::cout << std::endl << "Failure : " << failure_results << " Success : " << success_results << std::endl;
return failure_results;
}
示例9: test_override
static int test_override(void)
{
struct charge_port_info charge;
/* Initialize table to no charge */
initialize_charge_table(0, 5000, 1000);
/*
* Set a low-priority supplier on p0 and high-priority on p1, then
* verify that p1 is selected.
*/
charge.current = 500;
charge.voltage = 5000;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge_manager_update(CHARGE_SUPPLIER_TEST1, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 500);
/* Set override to p0 and verify p0 is selected */
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
/* Remove override and verify p1 is again selected */
charge_manager_set_override(OVERRIDE_OFF);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
/*
* Set override again to p0, but set p0 charge to 0, and verify p1
* is again selected.
*/
charge.current = 0;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
/* Set non-zero charge on port 0 and verify override was auto-removed */
charge.current = 250;
charge_manager_update(CHARGE_SUPPLIER_TEST5, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
/*
* Verify current limit is still selected according to supplier
* priority on the override port.
*/
charge.current = 300;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 300);
charge.current = 100;
charge_manager_update(CHARGE_SUPPLIER_TEST1, 0, &charge);
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 100);
/* Set override to "don't charge", then verify we're not charging */
charge_manager_set_override(OVERRIDE_DONT_CHARGE);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE);
TEST_ASSERT(active_charge_limit == 0);
/* Update a charge supplier, verify that we still aren't charging */
charge.current = 200;
charge_manager_update(CHARGE_SUPPLIER_TEST1, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE);
TEST_ASSERT(active_charge_limit == 0);
/* Turn override off, verify that we go back to the correct charge */
charge_manager_set_override(OVERRIDE_OFF);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 500);
return EC_SUCCESS;
}
示例10: test_dual_role
static int test_dual_role(void)
{
struct charge_port_info charge;
/* Initialize table to no charge. */
initialize_charge_table(0, 5000, 1000);
/*
* Mark P0 as dual-role and set a charge. Verify that we don't charge
* from the port.
*/
set_charger_role(0, DUAL_ROLE_CHARGER);
charge.current = 500;
charge.voltage = 5000;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE);
TEST_ASSERT(active_charge_limit == 0);
/* Mark P0 as the override port, verify that we now charge. */
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 500);
/* Remove override and verify we go back to not charging */
charge_manager_set_override(OVERRIDE_OFF);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE);
TEST_ASSERT(active_charge_limit == 0);
/* Mark P0 as the override port, verify that we again charge. */
charge_manager_set_override(0);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 500);
/* Insert a dedicated charger and verify override is removed */
charge.current = 400;
charge_manager_update(CHARGE_SUPPLIER_TEST6, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 400);
/*
* Verify the port is handled normally if the dual-role source is
* unplugged and replaced with a dedicated source.
*/
set_charger_role(0, DEDICATED_CHARGER);
charge.current = 0;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge.current = 500;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 500);
/*
* Verify that we charge from the dedicated port if a dual-role
* source is also attached.
*/
set_charger_role(0, DUAL_ROLE_CHARGER);
charge.current = 0;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge.current = 500;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 0, &charge);
charge.current = 200;
charge_manager_update(CHARGE_SUPPLIER_TEST6, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 200);
return EC_SUCCESS;
}
示例11: test_new_power_request
static int test_new_power_request(void)
{
struct charge_port_info charge;
/* Initialize table to no charge */
initialize_charge_table(0, 5000, 5000);
/* Clear power requests, and verify they are zero'd */
clear_new_power_requests();
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 0);
TEST_ASSERT(new_power_request[1] == 0);
/* Charge from port 1 and verify NPR on port 1 only */
charge.current = 1000;
charge.voltage = 5000;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 0);
TEST_ASSERT(new_power_request[1] == 1);
clear_new_power_requests();
/* Reduce port 1 through ceil and verify no NPR */
charge_manager_set_ceil(1, 500);
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 0);
TEST_ASSERT(new_power_request[1] == 0);
clear_new_power_requests();
/* Change port 1 voltage and verify NPR on port 1 */
charge.voltage = 4000;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 0);
TEST_ASSERT(new_power_request[1] == 1);
clear_new_power_requests();
/* Add low-priority source and verify no NPRs */
charge_manager_update(CHARGE_SUPPLIER_TEST6, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 0);
TEST_ASSERT(new_power_request[1] == 0);
clear_new_power_requests();
/*
* Add higher-priority source and verify NPR on both ports,
* since we're switching charge ports.
*/
charge_manager_update(CHARGE_SUPPLIER_TEST1, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(new_power_request[0] == 1);
TEST_ASSERT(new_power_request[1] == 1);
clear_new_power_requests();
return EC_SUCCESS;
}
示例12: test_priority
static int test_priority(void)
{
struct charge_port_info charge;
/* Initialize table to no charge */
initialize_charge_table(0, 5000, 5000);
TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE);
/*
* Set a 1A charge via a high-priority supplier and a 2A charge via
* a low-priority supplier, and verify the HP supplier is chosen.
*/
charge.current = 2000;
charge.voltage = 5000;
charge_manager_update(CHARGE_SUPPLIER_TEST6, 0, &charge);
charge.current = 1000;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 1000);
/*
* Set a higher charge on a LP supplier and verify we still use the
* lower charge.
*/
charge.current = 1500;
charge_manager_update(CHARGE_SUPPLIER_TEST7, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 1000);
/*
* Zero our HP charge and verify fallback to next highest priority,
* which happens to be a different port.
*/
charge.current = 0;
charge_manager_update(CHARGE_SUPPLIER_TEST2, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 2000);
/* Add a charge at equal priority and verify highest charge selected */
charge.current = 2500;
charge_manager_update(CHARGE_SUPPLIER_TEST5, 0, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 0);
TEST_ASSERT(active_charge_limit == 2500);
charge.current = 3000;
charge_manager_update(CHARGE_SUPPLIER_TEST6, 1, &charge);
wait_for_charge_manager_refresh();
TEST_ASSERT(active_charge_port == 1);
TEST_ASSERT(active_charge_limit == 3000);
return EC_SUCCESS;
}
示例13: main
int main(int argc, char *argv[])
{
struct vmx_pages *vmx_pages = NULL;
vm_vaddr_t vmx_pages_gva = 0;
struct kvm_regs regs1, regs2;
struct kvm_vm *vm;
struct kvm_run *run;
struct kvm_x86_state *state;
int stage;
struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
/* Create VM */
vm = vm_create_default(VCPU_ID, 0, guest_code);
vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
run = vcpu_state(vm, VCPU_ID);
vcpu_regs_get(vm, VCPU_ID, ®s1);
if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
} else {
printf("will skip nested state checks\n");
vcpu_args_set(vm, VCPU_ID, 1, 0);
}
for (stage = 1;; stage++) {
_vcpu_run(vm, VCPU_ID);
TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
"Unexpected exit reason: %u (%s),\n",
run->exit_reason,
exit_reason_str(run->exit_reason));
memset(®s1, 0, sizeof(regs1));
vcpu_regs_get(vm, VCPU_ID, ®s1);
switch (run->io.port) {
case GUEST_PORT_ABORT:
TEST_ASSERT(false, "%s at %s:%d", (const char *) regs1.rdi,
__FILE__, regs1.rsi);
/* NOT REACHED */
case GUEST_PORT_SYNC:
break;
case GUEST_PORT_DONE:
goto done;
default:
TEST_ASSERT(false, "Unknown port 0x%x.", run->io.port);
}
/* PORT_SYNC is handled here. */
TEST_ASSERT(!strcmp((const char *)regs1.rdi, "hello") &&
regs1.rsi == stage, "Unexpected register values vmexit #%lx, got %lx",
stage, (ulong) regs1.rsi);
state = vcpu_save_state(vm, VCPU_ID);
kvm_vm_release(vm);
/* Restore state in a new VM. */
kvm_vm_restart(vm, O_RDWR);
vm_vcpu_add(vm, VCPU_ID, 0, 0);
vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
vcpu_load_state(vm, VCPU_ID, state);
run = vcpu_state(vm, VCPU_ID);
free(state);
memset(®s2, 0, sizeof(regs2));
vcpu_regs_get(vm, VCPU_ID, ®s2);
TEST_ASSERT(!memcmp(®s1, ®s2, sizeof(regs2)),
"Unexpected register values after vcpu_load_state; rdi: %lx rsi: %lx",
(ulong) regs2.rdi, (ulong) regs2.rsi);
}
done:
kvm_vm_free(vm);
}
示例14: didCommitLoadForFrame
static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
{
WKRetainPtr<WKStringRef> wkMIME(AdoptWK, WKFrameCopyMIMEType(frame));
TEST_ASSERT(WKStringIsEqualToUTF8CString(wkMIME.get(), "image/png"));
}
示例15: main
/**
* Unit test's main function.
*/
int
main ()
{
/* int ecma_date_day (time)*/
TEST_ASSERT (ecma_date_day (0) == 0);
TEST_ASSERT (ecma_date_day (MS_PER_DAY) == 1);
/* ecma_number_t ecma_date_time_within_day (time) */
TEST_ASSERT (ecma_date_time_within_day (0) == 0);
TEST_ASSERT (ecma_date_time_within_day (42) == 42);
TEST_ASSERT (ecma_date_time_within_day (42.51) == 42.51);
TEST_ASSERT (ecma_date_time_within_day (MS_PER_DAY + 42) == 42);
/* int ecma_date_year_from_time (time) */
TEST_ASSERT (ecma_date_year_from_time (0) == 1970);
TEST_ASSERT (ecma_date_year_from_time (0) == 1970);
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY) == 1970);
TEST_ASSERT (ecma_date_year_from_time ((MS_PER_DAY) * (ecma_number_t) 365 - 1) == 1970);
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) 365) == 1971);
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365 * (2015 - 1970)))
== 2014);
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365.25 * (2015 - 1970)))
== 2015);
TEST_ASSERT (ecma_date_year_from_time (-MS_PER_YEAR) == 1969);
TEST_ASSERT (ecma_date_year_from_time (-1970 * MS_PER_YEAR) == 1);
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 1) == -1);
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 3 * MS_PER_YEAR) == -3);
/* int ecma_date_month_from_time (time) */
TEST_ASSERT (ecma_date_month_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_month_from_time (0) == 0);
TEST_ASSERT (ecma_date_month_from_time (-MS_PER_DAY) == 11);
TEST_ASSERT (ecma_date_month_from_time (31 * MS_PER_DAY) == 1);
/* int ecma_date_date_from_time (time) */
TEST_ASSERT (ecma_date_date_from_time (START_OF_GREGORIAN_CALENDAR) == 1);
TEST_ASSERT (ecma_date_date_from_time (0) == 1);
TEST_ASSERT (ecma_date_date_from_time (-MS_PER_DAY) == 31);
TEST_ASSERT (ecma_date_date_from_time (31 * MS_PER_DAY) == 1);
/* int ecma_date_week_day (ecma_number_t time) */
/* FIXME: Implement */
/* ecma_number_t ecma_date_utc (time) */
/* FIXME: Implement */
/* ecma_number_t ecma_date_hour_from_time (time) */
TEST_ASSERT (ecma_date_hour_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_hour_from_time (0) == 0);
TEST_ASSERT (ecma_date_hour_from_time (-MS_PER_DAY) == 0);
TEST_ASSERT (ecma_date_hour_from_time (-1) == 23);
/* ecma_number_t ecma_date_min_from_time (time) */
TEST_ASSERT (ecma_date_min_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_min_from_time (0) == 0);
TEST_ASSERT (ecma_date_min_from_time (-MS_PER_DAY) == 0);
TEST_ASSERT (ecma_date_min_from_time (-1) == 59);
/* ecma_number_t ecma_date_sec_from_time (time) */
TEST_ASSERT (ecma_date_sec_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_sec_from_time (0) == 0);
TEST_ASSERT (ecma_date_sec_from_time (-MS_PER_DAY) == 0);
TEST_ASSERT (ecma_date_sec_from_time (-1) == 59);
/* ecma_number_t ecma_date_ms_from_time (time) */
TEST_ASSERT (ecma_date_ms_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
TEST_ASSERT (ecma_date_ms_from_time (0) == 0);
TEST_ASSERT (ecma_date_ms_from_time (-MS_PER_DAY) == 0);
TEST_ASSERT (ecma_date_ms_from_time (-1) == 999);
/* ecma_number_t ecma_date_make_time (hour, min, sec, ms) */
/* FIXME: Implement */
/* ecma_number_t ecma_date_make_day (year, month, date) */
TEST_ASSERT (ecma_date_make_day (1970, 0, 1) == 0);
TEST_ASSERT (ecma_date_make_day (1970, -1, 1) == -31);
TEST_ASSERT (ecma_date_make_day (1970, 0, 2.5) == 1);
TEST_ASSERT (ecma_date_make_day (1970, 1, 35) == 65);
TEST_ASSERT (ecma_date_make_day (1970, 13, 35) == 430);
TEST_ASSERT (ecma_date_make_day (2016, 2, 1) == 16861);
TEST_ASSERT (ecma_date_make_day (2016, 8, 31) == 17075);
TEST_ASSERT (ecma_date_make_day (2016, 9, 1) == 17075);
//.........这里部分代码省略.........