Example #1
0
void test_set_complement() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	Set* source = new Set();
	String* val3 = new String("value 3");
	String* val4 = new String("value 4");
	source->Add(val3);
	source->Add(val4);

	cout << "Target:" << endl << *target << endl << endl << flush;
	cout << "Source:" << endl << *source << endl << endl << flush;

	target->Complement(source);

	cout << "After union Target:" << endl << *target << endl << endl << flush;

	ASSERT_EQUAL(2, target->Size());

	delete target;
	delete source;
	delete val1;
	delete val2;
	delete val3;
	delete val4;
}
Example #2
0
void test_set_intersect() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	Set* source = new Set();
	String* val3 = new String("value 1");
	String* val4 = new String("value 4");
	source->Add(val3);
	source->Add(val4);

	cout << "Target:" << endl << *target << endl << endl << flush;
	cout << "Source:" << endl << *source << endl << endl << flush;

	target->Intersect(source);

	cout << "AFter intersect Target:" << endl << *target << endl << endl
			<< flush;

	ASSERT_EQUAL(1, target->Size());

	delete target;
	delete source;
	delete val1;
	delete val2;
	delete val3;
	delete val4;
}
Example #3
0
// #########################################################
// Add, Append, Prepend tests
// #########################################################
void test_set_add_multpile_values() {
	Set* set = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	String* val3 = new String("value 3");
	String* val4 = new String("value 4");

	set->Add(val1);
	set->Add(val2);
	set->Add(val3);
	set->Add(val4);
	/* Add duplicates */
	set->Add(val1);
	set->Add(val2);

	cout << *set << endl << flush;

	ASSERT_EQUAL(4, set->Size());

	delete set;
	delete val1;
	delete val2;
	delete val3;
	delete val4;
}
TEST(Set, ThreeItems) {
  Set<int> s;

  EXPECT_TRUE(s.Add(0));
  EXPECT_TRUE(s.Add(1));
  EXPECT_TRUE(s.Add(2));

  EXPECT_FALSE(s.Has(-1));
  EXPECT_TRUE(s.Has(0));
  EXPECT_TRUE(s.Has(1));
  EXPECT_TRUE(s.Has(2));
  EXPECT_FALSE(s.Has(3));

  EXPECT_EQ(3U, s.GetCount());
}
TEST(Set, OneItem) {
  Set<int> s;

  EXPECT_FALSE(s.Has(0));

  EXPECT_TRUE(s.Add(0));
  EXPECT_TRUE(s.Has(0));
  EXPECT_FALSE(s.IsEmpty());
  EXPECT_EQ(1U, s.GetCount());
}
void Style::AddExtensions(CString& ext)
{
	Set<CString>*	list = iExtensions.GetUnresolved();

	if (!list)
		{
		iExtensions.SetPtr(list = new Set<CString>);
		}

	list->Add(new CString(ext));
}
void Style::AddNumericPrefix(CString& numericPrefix)
{
	Set<CString>*	list = iNumericPrefix.GetUnresolved();

	if (!list)
		{
		iNumericPrefix.SetPtr(list = new Set<CString>);
		}

	list->Add(new CString(numericPrefix));
}
void Style::AddEolComment(CString& eolComment)
{
	Set<CString>*	list = iEolComment.GetUnresolved();

	if (!list)
		{
		iEolComment.SetPtr(list = new Set<CString>);
		}

	list->Add(new CString(eolComment));
}
void Style::AddCloseComment(CString& closeComment)
{
	Set<CString>*	list = iCloseComment.GetUnresolved();

	if (!list)
		{
		iCloseComment.SetPtr(list = new Set<CString>);
		}

	list->Add(new CString(closeComment));
}
void Style::AddOpenComment(CString& openComment)
{
	Set<CString>*	list = iOpenComment.GetUnresolved();

	if (!list)
		{
		iOpenComment.SetPtr(list = new Set<CString>);
		}

	list->Add(new CString(openComment));
}
Example #11
0
Set Set::GetPossibilitiesFor(int number) {

	Set set = Set();
	
	for (int i = 0; i < filled; i++) {
		if ( squares[i]->CanHave(number) )
			set.Add(squares[i]);
	}

	return set;
}
Example #12
0
// #########################################################
// Intersect
// #########################################################
void test_set_intersect_null_source() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	target->Intersect(nullptr);

	ASSERT_EQUAL(2, target->Size());

	delete target;
	delete val1;
	delete val2;
}
Example #13
0
void test_set_intersect_empty_source() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	Set* source = new Set();

	target->Intersect(source);

	ASSERT_EQUAL(0, target->Size());

	delete target;
	delete source;
	delete val1;
	delete val2;
}
Example #14
0
// #########################################################
// complement tests
// #########################################################
void test_set_complement_null_source() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	cout << "Target:" << endl << *target << endl << endl << flush;

	target->Complement(nullptr);

	cout << "After union Target:" << endl << *target << endl << endl << flush;

	ASSERT_EQUAL(2, target->Size());

	delete target;
	delete val1;
	delete val2;
}
Example #15
0
void test_set_remove() {
	Set* set = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");

	set->Add(val1);
	set->Add(val2);

	cout << "Before remove:" << endl << *set << endl << endl << flush;

	set->Remove(val2);

	cout << "After remove:" << endl << *set << endl << flush;

	ASSERT_EQUAL(1, set->Size());

	delete set;
	delete val1;
	delete val2;
}
Example #16
0
void test_set_union_empty_source() {
	Set* target = new Set();
	String* val1 = new String("value 1");
	String* val2 = new String("value 2");
	target->Add(val1);
	target->Add(val2);

	Set* source = new Set();

	cout << "Target:" << endl << *target << endl << endl << flush;
	cout << "Source:" << endl << *source << endl << endl << flush;

	target->Union(source);

	cout << "After union Target:" << endl << *target << endl << endl << flush;

	ASSERT_EQUAL(2, target->Size());

	delete target;
	delete source;
	delete val1;
	delete val2;
}
Example #17
0
	void SelectMap(int32 newIndex)
	{
		Set<MapIndex*> visibleMaps;
		auto& srcCollection = m_SourceCollection();
		auto it = srcCollection.find(newIndex);
		if(it != srcCollection.end())
		{
			const float initialSpacing = 0.65f * m_style->frameMain->GetSize().y;
			const float spacing = 0.8f * m_style->frameSub->GetSize().y;
			const Anchor anchor = Anchor(0.0f, 0.5f, 1.0f, 0.5f);

			static const int32 numItems = 10;

			int32 istart;
			for(istart = 0; istart > -numItems;)
			{
				if(it == srcCollection.begin())
					break;
				it--;
				istart--;
			}

			for(int32 i = istart; i <= numItems; i++)
			{
				if(it != srcCollection.end())
				{
					visibleMaps.Add(it->second);

					// Add a new map slot
					bool newItem = m_guiElements.find(it->second) == m_guiElements.end();
					Ref<SongSelectItem> item = m_GetMapGUIElement(it->second);
					float offset = 0;
					if(i != 0)
					{
						offset = initialSpacing * Math::Sign(i) +
							spacing * (i - Math::Sign(i));
					}
					Canvas::Slot* slot = Add(item.As<GUIElementBase>());

					int32 z = -abs(i);
					slot->SetZOrder(z);

					slot->anchor = anchor;
					slot->autoSizeX = true;
					slot->autoSizeY = true;
					slot->alignment = Vector2(0, 0.5f);
					if(newItem)
					{
						// Hard set target position
						slot->offset.pos = Vector2(0, offset);
						slot->offset.size.x = z * 50.0f;
					}
					else
					{
						// Animate towards target position
						item->AddAnimation(Ref<IGUIAnimation>(
							new GUIAnimation<Vector2>(&slot->offset.pos, Vector2(0, offset), 0.1f)), true);
						item->AddAnimation(Ref<IGUIAnimation>(
							new GUIAnimation<float>(&slot->offset.size.x, z * 50.0f, 0.1f)), true);
					}

					item->fade = 1.0f - ((float)abs(i) / (float)numItems);
					item->innerOffset = item->fade * 100.0f;

					if(i == 0)
					{
						m_OnMapSelected(it->second);
					}

					it++;
				}
			}
		}
		m_currentlySelectedId = newIndex;

		// Cleanup invisible elements
		for(auto it = m_guiElements.begin(); it != m_guiElements.end();)
		{
			if(!visibleMaps.Contains(it->first))
			{
				Remove(it->second.As<GUIElementBase>());
				it = m_guiElements.erase(it);
				continue;
			}
			it++;
		}
	}