MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_multi_import_manager

Function test_multi_import_manager

tests/basic/test-attribute.cpp:558–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558void test_multi_import_manager()
559{
560 geode::AttributeManager from1;
561 from1.resize( 10 );
562 auto attr1_from1 = from1.find_or_create_attribute< geode::VariableAttribute,
563 geode::index_t >( "variable", 42 );
564 for( const auto i : geode::LRange( from1.nb_elements() ) )
565 {
566 attr1_from1->set_value( i, i );
567 }
568 auto attr2_from1 =
569 from1.find_or_create_attribute< geode::ConstantAttribute, double >(
570 "constant", 1.0 );
571 auto attr3_from1 =
572 from1.find_or_create_attribute< geode::SparseAttribute, std::string >(
573 "sparse", "default" );
574 attr3_from1->set_value( 1, "one" );
575
576 geode::AttributeManager from2;
577 from2.resize( 10 );
578 auto attr1_from2 = from2.find_or_create_attribute< geode::VariableAttribute,
579 geode::index_t >( "variable", 42 );
580 for( const auto i : geode::LRange( from2.nb_elements() ) )
581 {
582 attr1_from2->set_value( i, from2.nb_elements() - i );
583 }
584 auto attr2_from2 =
585 from2.find_or_create_attribute< geode::ConstantAttribute, double >(
586 "constant", 2.0 );
587 auto attr3_from2 =
588 from2.find_or_create_attribute< geode::SparseAttribute, std::string >(
589 "sparse", "another_default" );
590 attr3_from2->set_value( 2, "two" );
591
592 geode::GenericMapping< geode::index_t > from1_to;
593 from1_to.map( 1, 0 );
594 from1_to.map( 3, 1 );
595 from1_to.map( 5, 2 );
596 from1_to.map( 7, 3 );
597 from1_to.map( 9, 4 );
598 geode::GenericMapping< geode::index_t > from2_to;
599 from2_to.map( 0, 5 );
600 from2_to.map( 2, 6 );
601 from2_to.map( 4, 7 );
602 from2_to.map( 6, 8 );
603 from2_to.map( 8, 9 );
604
605 geode::AttributeManager to;
606 to.resize( 10 );
607 to.import( from1, from1_to );
608 to.import( from2, from2_to );
609
610 geode::OpenGeodeBasicException::test( to.nb_elements() == 10,
611 "Wrong number of elements for AttributeManger to" );
612
613 std::array< geode::index_t, 10 > answer_variable{ 1, 3, 5, 7, 9, 10, 8, 6,
614 4, 2 };
615 std::array< double, 10 > answer_constant{ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,

Callers 1

testFunction · 0.85

Calls 7

testFunction · 0.70
resizeMethod · 0.45
nb_elementsMethod · 0.45
set_valueMethod · 0.45
mapMethod · 0.45
importMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected