TEST(EventListTest, testAddWithInternalId) { Event::List list; Event a(0, EventType::NOTE); Event b(0, EventType::NOTE); int idOfA = list.add(a, 100); int idOfB = list.add(b, 2); EXPECT_EQ(100, idOfA); EXPECT_EQ(2, idOfB); EXPECT_EQ(100, list.get(0)->id); EXPECT_EQ(2, list.get(1)->id); }
TEST(EventListTest, testRemoveAt) { Event::List list; Event a(0, EventType::NOTE); Event b(0, EventType::NOTE); list.add(a, 100); list.add(b, 2); EXPECT_EQ(100, list.get(0)->id); EXPECT_EQ(2, list.get(1)->id); EXPECT_EQ(2, list.size()); list.removeAt(0); EXPECT_EQ(1, list.size()); EXPECT_EQ(2, list.get(0)->id); }
TEST(EventListTest, testGetAndSetElement) { Event::List list; Event a(0, EventType::NOTE); Event b(0, EventType::NOTE); list.add(a, 100); list.add(b, 2); EXPECT_EQ(100, list.get(0)->id); EXPECT_EQ(2, list.get(1)->id); Event c(480, EventType::NOTE); c.id = 99; list.set(1, c); EXPECT_EQ(100, list.get(0)->id); EXPECT_EQ(2, list.get(1)->id); EXPECT_EQ((tick_t)480, list.get(1)->tick); }
TEST(EventListTest, testAddWithoutInternalId) { Event::List list; Event a(1, EventType::NOTE); Event b(0, EventType::NOTE); int idOfA = list.add(a); int idOfB = list.add(b); // bよりaのほうがtickが大きいので, 並べ替えが起きるはず EXPECT_EQ(idOfB, list.get(0)->id); EXPECT_EQ(idOfA, list.get(1)->id); EXPECT_TRUE(idOfA != idOfB); }
TEST(EventListTest, testSetForId) { Event::List listA; Event event(0, EventType::NOTE); event.note = 60; event.id = 10; Event replace(0, EventType::NOTE); replace.note = 90; replace.id = 100; listA.add(event, 10); listA.setForId(10, replace); EXPECT_EQ(10, listA.get(0)->id); EXPECT_EQ(90, listA.get(0)->note); // 無効なinternalIdを渡すので, setが行われない場合 Event::List listB; listB.add(event, 10); listB.setForId(9999, replace); EXPECT_EQ(60, listB.get(0)->note); }
TEST(EventListTest, testClear) { Event::List list; Event b(480, EventType::NOTE); Event a(0, EventType::NOTE); list.add(b, 14); list.add(a, 20); EXPECT_EQ(2, list.size()); EXPECT_EQ(20, list.get(0)->id); list.clear(); EXPECT_EQ(0, list.size()); }
/** * @brief 反復子の次の要素を探索する * @return (int) 次のインデックス */ int _nextPosition() const{ int count = _list->size(); for( int i = _pos + 1; i < count; ++i ){ const Event *item = _list->get( i ); if( _kindSinger ){ if( item->type == EventType::SINGER ){ return i; } } if( _kindNote ){ if( item->type == EventType::NOTE ){ return i; } } if( _kindDynaff || _kindCrescend || _kindDecrescend ){ if( item->type == EventType::ICON && item->iconDynamicsHandle.getHandleType() != HandleType::UNKNOWN ) { if( _kindDynaff ){ if( item->iconDynamicsHandle.isDynaffType() ){ return i; } } if( _kindCrescend ){ if( item->iconDynamicsHandle.isCrescendType() ){ return i; } } if( _kindDecrescend ){ if( item->iconDynamicsHandle.isDecrescendType() ){ return i; } } } } } return -1; }