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


C++ Tester::warn方法代码示例

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


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

示例1: main

int main()
{
	// PICTURE
	Tester 	*tester = new Tester("Picture");
	Picture p;

	tester->test(p.data, std::string(""),
		"constructor without filename make an empty string");

	p.getPictureFromFile(std::string("file.test"));
	tester->test(p.data, std::string("this is a test\ncool"),
		"when a correct filename is provided, it correctly reads the file");

	p.getPictureFromFile(std::string("notExistingFile.test"));
	tester->test(p.data, std::string("ERROR"),
		"when there is an error, the string is set to ERROR");

	delete tester;
	// PICTURE

	// TOY
	tester = new Tester("Toy");
	Toy		t;

	tester->test(t.getType(), Toy::BASIC_TOY,
		"default constructor set the type to BASIC_TOY");
	tester->test(t.getName(), std::string("toy"),
		"default constructor set the name to toy");
	tester->test(t.getAscii(), std::string(""),
		"default constructor set the ascii to ''");

	Toy 	t2(Toy::ALIEN, std::string("E.T"), std::string("file.test"));

	tester->test(t2.getType(), Toy::ALIEN,
		"constructor set the type correctly");
	tester->test(t2.getName(), std::string("E.T"),
		"constructor set the name correctly");
	tester->test(t2.getAscii(), std::string("this is a test\ncool"),
		"constructor set the ascii correctly");

	t = t2;

	tester->test(t.getType(), t2.getType() ,
		"operator= set the type correctly");
	tester->test(t.getName(), t2.getName(),
		"operator= set the name correctly");
	tester->test(t.getAscii(), t2.getAscii(),
		"operator= set the ascii correctly");

	delete tester;
	// TOY

	// BUZZ + WOODY
	tester = new Tester("Buzz and Woody");

	Buzz 	buzz(std::string("foo"));
	Woody 	woody(std::string("bar"), std::string("file.test"));

	tester->test(buzz.getType(), Toy::BUZZ,
		"Buzz constructor (no file) set the type correctly");
	tester->test(buzz.getName(), std::string("foo"),
		"Buzz constructor (no file) set the name correctly");
	tester->test(buzz.getAscii(), std::string("Buzz !!!"),
		"Buzz constructor (no file) set the ascii correctly");	

	tester->test(woody.getType(), Toy::WOODY,
		"Woody constructor set the type correctly");
	tester->test(woody.getName(), std::string("bar"),
		"Woody constructor set the name correctly");
	tester->test(woody.getAscii(), std::string("this is a test\ncool"),
		"Woody constructor set the ascii correctly");


	tester->warn("The following tests cannot be unit tested, please check by hand");
	t.speak("I cannot unit test this... Does it work ? (toy)");
	buzz.speak("I cannot unit test this... Does it work ? (buzz)");
	woody.speak("I cannot unit test this... Does it work ? (woody)");

	delete tester;
	// BUZZ + WOODY

	// OPERATOR<<
	tester = new Tester("operator<<");

	t << "woohoo";

	tester->test(t.getAscii(), std::string("woohoo"),
		"operator<< with TOY and STRING");

	tester->warn("The following test cannot be unit tested, please check by hand");
	std::cout << t;

	delete tester;
	// OPERATOR<<

	return 0;
}
开发者ID:4rzael,项目名称:pool_tests,代码行数:97,代码来源:main.cpp


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