Ejemplo n.º 1
0
  void IntegerInvalidString()
  {
    Integer base;
    QString bad = "ABCD";
    QString good = base.ToString();

    EXPECT_NE(bad, Integer(bad).ToString());
    EXPECT_EQ(base, Integer(good));
  }
Ejemplo n.º 2
0
 TEST(Integer, ModInverse)
 {
   Integer mod = Integer::GetRandomInteger(1024);
   // mod should be prime to ensure (higher likelihood of) multiplicative inverse
   mod = Integer::GetRandomInteger(1024, mod, true);
   Integer val = Integer::GetRandomInteger(1024, mod);
   Integer mi = val.ModInverse(mod);
   Integer result = (val * mi) % mod;
   qDebug() << result.ToString() << (val < mod) << (mi < mod);
   EXPECT_EQ(result, 1);
 }
Ejemplo n.º 3
0
/*
 * Array : ["key","value"; "key2",2; "key3",JsonObject*]
 *
 * {
 * 	key: 'key',
 *  key2: 2,
 *  key3: {...}
 *  }
 */
String
Json::StringifyValue(MapEntryT<String, Object* >* item){
	String entry;
	if (__type == AArrayType){
		entry.Append("\"");
		entry.Append(item->GetKey());
		entry.Append("\":");
	}

	Object* value = item->GetValue();

	if (value == NULL){
		AppLog("JSON SERIALIZED: value is null");
		return "\"\"";
	}

	String *string = dynamic_cast<String*>(value);
	if (string != NULL){
		entry.Append(Json::StringifyString(string));
		return entry;
	}
	Integer *integer = dynamic_cast<Integer*>(value);
	if (integer != NULL){
		entry.Append(integer->ToString());
		return entry;
	}

	Json *json = dynamic_cast<Json*>(value);
	if (json != NULL){
		entry.Append(json->Stringify());
		return entry;
	}

	entry.Append("'unknown type'");
	return entry;
}
Ejemplo n.º 4
0
void
EditPanel::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPosition)
{
	int i;
	Rectangle *tmp_rect, *tmp_rect2;
	static int old_scrollPosition = 0;
	static int start_point = 0;
	int scrollgap = 0;
	int current_y = start_point;
	Integer a;
	String s;

	if(old_scrollPosition < scrollPosition)
	{
		scrollgap = scrollPosition - old_scrollPosition;
		if(scrollPosition == scroll_end_point)
		{
			start_point = 0 - scroll_end_point;
		}
		else
		{
			start_point -= scrollgap;
		}
		current_y = start_point;
	}

	else if(old_scrollPosition > scrollPosition)
	{
		scrollgap = old_scrollPosition - scrollPosition;
		if(scrollPosition == 0)
		{
			start_point = 0;
		}
		else
		{
			start_point += scrollgap;
		}
		current_y = start_point;
	}
	s = a.ToString(current_y);

	AppLog("current_y : %S", s.GetPointer());


	s =  a.ToString(scrollPosition);

	AppLog("scrollPositoin : %S", s.GetPointer());

	for(i=0; i<arr_text_element.GetCount(); i++)
	{
		tmp_rect = static_cast< Rectangle* > (arr_text_element_rect.GetAt(i));

		arr_text_element_rect.SetAt(new Rectangle(tmp_rect->x, current_y, tmp_rect->width, tmp_rect->height), i);

		if(i+1 < arr_text_element.GetCount())
		{
			tmp_rect2 = static_cast< Rectangle* > (arr_text_element_rect.GetAt(i+1));

			if(tmp_rect->y < tmp_rect2->y)
				current_y += STRIATION_SPACING;
		}
	}

	old_scrollPosition = scrollPosition;
}
Ejemplo n.º 5
0
//**********************************************************************************************
//*************************         Преобразование в строку       ******************************
	std::string Converter::ToString(const Integer &integer, NumericSystem system)
	{
		return integer.ToString(system);
	}
Ejemplo n.º 6
0
void
ProfileDetailForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
{
	result r = E_SUCCESS;

	if (pArgs != null)
	{
		Integer* pId = static_cast< Integer* >(pArgs->GetAt(0));

		if (pId == null)
		{
			MessageBox messageBox;
			String getError, getFailGet;
			Application::GetInstance()->GetAppResource()->GetString(IDS_ERROR, getError);
			Application::GetInstance()->GetAppResource()->GetString(IDS_FAIL_GET, getFailGet);
			messageBox.Construct(getError, getFailGet, MSGBOX_STYLE_OK, 0);
			int doModal;
			messageBox.ShowAndWait(doModal);

			AppLogException("[%s] Failed to get Profile.", GetErrorMessage(r));
		}
		else
		{
			__currentID = pId->ToInt();
			String* pSubjectValue = static_cast< String* >(pArgs->GetAt(1));
			if (pSubjectValue == null) {
				__pSubjectLabelData->SetText(L"(No subject)");
			} else {
				__pSubjectLabelData->SetText(*pSubjectValue);
			}
			Integer* pYear = static_cast< Integer* >(pArgs->GetAt(2));
			Integer* pMonth = static_cast< Integer* >(pArgs->GetAt(3));
			Integer* pDay = static_cast< Integer* >(pArgs->GetAt(4));
			Integer* pHour = static_cast< Integer* >(pArgs->GetAt(5));
			Integer* pMinute = static_cast< Integer* >(pArgs->GetAt(6));
			String startString;
			startString.Format(30, L"%d/%02d/%02d %02d:%02d", pYear->ToInt(), pMonth->ToInt(), pDay->ToInt(), pHour->ToInt(), pMinute->ToInt());
			__pStartDateLabelData->SetText(startString);
			Integer* pYear2 = static_cast< Integer* >(pArgs->GetAt(7));
			Integer* pMonth2 = static_cast< Integer* >(pArgs->GetAt(8));
			Integer* pDay2 = static_cast< Integer* >(pArgs->GetAt(9));
			Integer* pHour2 = static_cast< Integer* >(pArgs->GetAt(10));
			Integer* pMinute2 = static_cast< Integer* >(pArgs->GetAt(11));
			String startString2;
			startString2.Format(30, L"%d/%02d/%02d %02d:%02d", pYear2->ToInt(), pMonth2->ToInt(), pDay2->ToInt(), pHour2->ToInt(), pMinute2->ToInt());
			__pDueDateLabelData->SetText(startString2);
			//TODO: Should be modified!!!!

			Double* pX = static_cast< Double* > ( pArgs->GetAt(12));
			Double* pY = static_cast< Double* > ( pArgs->GetAt(13));

			String pointStr = pX->ToString() + " , " + pY->ToString();

			__pLocationLabelData->SetText(pointStr);

			Integer* pVolume = static_cast< Integer* >(pArgs->GetAt(14));
			__pVolumeLabelData->SetText(pVolume->ToString());
			Integer* pWifi = static_cast< Integer* >(pArgs->GetAt(15));
			__pWifiLabelData->SetText(pWifi->ToInt()==1?"On":"Off");
			String* pMemo = static_cast< String* >(pArgs->GetAt(16));
			String PropertyValue = L"(No description)";
			if (pMemo != null) {
				PropertyValue = *pMemo;
			}
			__pDescriptionLabelData->SetText(PropertyValue);

			Invalidate(true);
		}

		pArgs->RemoveAll(true);
		delete pArgs;
	}
}
void Enrollment::OnSceneActivatedN(
		const Tizen::Ui::Scenes::SceneId& previousSceneId,
		const Tizen::Ui::Scenes::SceneId& currentSceneId,
		Tizen::Base::Collection::IList* pArgs) {

	AppLog("ChatFrm::OnSceneActivatedN");

	Ip4Address* pAddress = null;

	if (pArgs != null) {
		if (pArgs->GetCount()) {
			Boolean* pServer = dynamic_cast<Boolean*>(pArgs->GetAt(0));
			TryCatch(pServer != null, ,
					"Failed to retrieve the client/server from the Array list.");

			__isServer = pServer->ToBool();

			if (__isServer) {
				Integer* pPort = dynamic_cast<Integer*>(pArgs->GetAt(1));
				TryCatch(pPort != null, ,
						"Failed to retrieve the port number from the Array list.");

				__port = pPort->ToInt();

				Boolean* pProtocol = dynamic_cast<Boolean*>(pArgs->GetAt(2));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the protocol type from the Array list.");

				__isTcp = pProtocol->ToBool();

				Integer* pYear = dynamic_cast<Integer*>(pArgs->GetAt(3));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the year from the Array list.");

				__year = pYear->ToInt();

				Integer* pMonth = dynamic_cast<Integer*>(pArgs->GetAt(4));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the month from the Array list.");

				__month = pMonth->ToInt();

				Integer* pDay = dynamic_cast<Integer*>(pArgs->GetAt(5));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the month from the Array list.");
				__day = "";
				__day = pDay->ToString();
				if (__day == "") {
					AppLog("Day Error");
				};

				String myDay = "";
				myDay.Append(__year);
				myDay.Append("/");
				myDay.Append(__month);
				myDay.Append("/");
				myDay.Append(__day);
				myDay.Append("");

				__pDate->SetText(myDay);

			} else {
				pAddress = dynamic_cast<Ip4Address*>(pArgs->GetAt(1));
				TryCatch(pAddress !=null, ,
						"Failed to retrieve the Ipaddress from the Array list.");

				Integer* pPort = dynamic_cast<Integer*>(pArgs->GetAt(2));
				TryCatch(pPort != null, ,
						"Failed to retrieve the port number from the Array list.");

				__port = pPort->ToInt();

				Boolean* pProtocol = dynamic_cast<Boolean*>(pArgs->GetAt(3));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the protocol type from the Array list.");

				__isTcp = pProtocol->ToBool();

				Integer* pYear = dynamic_cast<Integer*>(pArgs->GetAt(3));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the year from the Array list.");

				__year = pYear->ToInt();

				Integer* pMonth = dynamic_cast<Integer*>(pArgs->GetAt(4));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the month from the Array list.");

				__month = pMonth->ToInt();

				Integer* pDay = dynamic_cast<Integer*>(pArgs->GetAt(5));
				TryCatch(pProtocol != null, ,
						"Failed to retrieve the month from the Array list.");
				__day = "";
				__day = pDay->ToString();
				if (__day == "") {
					AppLog("Day Error");
				};

				String myDay = "";
				myDay.Append(__year);
				myDay.Append("/");
				myDay.Append(__month);
				myDay.Append("/");
				myDay.Append(__day);
				myDay.Append(".");

				__pDate->SetText(myDay);

			}
		}