当前位置: 首页>>代码示例>>C++>>正文


C++ Notification::SetError方法代码示例

本文整理汇总了C++中Notification::SetError方法的典型用法代码示例。如果您正苦于以下问题:C++ Notification::SetError方法的具体用法?C++ Notification::SetError怎么用?C++ Notification::SetError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notification的用法示例。


在下文中一共展示了Notification::SetError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestAllocateNotificationMessage

TEST_RESULT TestAllocateNotificationMessage()
{
	std::cout << "create noti with no cid" << std::endl;
	{
		std::stringstream messageToBeSent;
		Message * noti  = new AllocateNotification("gutentag");

		noti->Write(messageToBeSent);
		std::cout << messageToBeSent.str() << std::endl;
	}

	std::cout << "create noti with cid" << std::endl;
	{
		std::stringstream messageToBeSent;
		Message * noti = new AllocateNotification("gutentag", 15);

		noti->Write(messageToBeSent);
		std::cout << messageToBeSent.str() << std::endl;
	}

	std::cout << "create noti with error" << std::endl;
	{
		std::stringstream messageToBeSent;
		Notification * noti = new AllocateNotification("gutentag", 15);
		noti->SetError(ERRORCODE_WRONG_CHANNELID, "crab happened");
		noti->Write(messageToBeSent);
		std::cout << messageToBeSent.str() << std::endl;
	}

	std::cout << "create Allocate noti with error and cid" << std::endl;
	{
		std::stringstream messageToBeSent;
		AllocateNotification * noti = new AllocateNotification("gutentag", 15);
		noti->SetError(ERRORCODE_WRONG_CHANNELID, "crab happened 2");
		noti->Write(messageToBeSent);
		std::cout << messageToBeSent.str() << std::endl;

		pugi::xml_document* doc = new pugi::xml_document();
		ParseResponse(doc, ( char*)(messageToBeSent.str().c_str()));
		AllocateNotification * res = new AllocateNotification(doc);

		std::cout << "channel id" << res->GetChannelId() << std::endl;
		ErrorCode errc;
		const char * errstr;
		res->GetError(errc, errstr);
		std::string messageName = res->GetMessageName();

		std::cout << "message name" << messageName << std::endl;
		std::cout << "err code" << errc << std::endl;
		std::cout << "err str" << errstr << std::endl;


	}

	std::cout << "test static functionality" << std::endl;
		{
			std::stringstream messageToBeSent;
			AllocateNotification * noti = new AllocateNotification("gutentag", 25);
			noti->SetError(ERRORCODE_WRONG_CHANNELID, "crab happened 3");
			noti->Write(messageToBeSent);
			std::cout << messageToBeSent.str() << std::endl;

			pugi::xml_document* doc = new pugi::xml_document();
			ParseResponse(doc, ( char*)(messageToBeSent.str().c_str()));

			if (Notification::NOTIFICATIONTTYPE_ALLOCATE == Notification::GetNotificationType(doc))
				std::cout << "type obtained properly" << std::endl;

			std::cout << "tag" << Notification::GetNotificationTag(doc) << std::endl;

		}


	return PASSED;

}
开发者ID:,项目名称:,代码行数:76,代码来源:


注:本文中的Notification::SetError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。