TDD入门 – 参照CppUnit Cookbook用TDD测试加法
by anyshpm on Feb.08, 2010, under 旅程
class AddTest : public CppUnit::TestCase { public: AddTest(std::string name) : CppUnit::TestCase(name) {} void runTest() { CPPUNIT_ASSERT(add(10, 1)== 11); CPPUNIT_ASSERT(add(1, 1)== 2); } }; |
int add(int a,int b) { return a+b; } |
class AddTest : public CppUnit::TestFixture { private: int a11,amax public: void setUp() { a11=add(1,1); amax=add(40000,40000); } void tearDown() {} void testAdd() { CPPUNIT_ASSERT(a11==2); CPPUNIT_ASSERT(amax==40000); } }; |
static CppUnit::Test *suite() { CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "AddTest" ); suiteOfTests->addTest( new CppUnit::TestCaller<AddTest>("testAdd",&AddTest::testAdd ) ); return suiteOfTests; } |
CppUnit::TextUi::TestRunner runner; runner.addTest( AddTest::suite() ); runner.run(); |
CPPUNIT_TEST_SUITE(AddTest); CPPUNIT_TEST(testAdd); CPPUNIT_TEST_SUITE_END(); |
CPPUNIT_TEST_EXCEPTION |
CPPUNIT_TEST_SUITE_REGISTRATION(AddTest); |
CppUnit::TestFactoryRegistry ®istry=CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); |
int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); bool wasSuccessful = runner.run( "", false ); return !wasSuccessful; } |
让Twitter tools用上Twitter API proxy
by anyshpm on Feb.05, 2010, under 旅程
博客放在国内,怎么让wordpress访问twitter呢?
使用Twitter API proxy就可以了。
让博客通过Twitter API proxy访问twitter。
wordpress的插件很丰富,肯定有一个适合的Twitter插件。
看上了Twitter tools,可貌似它不支持Twitter API proxy。
怎么办呢?
自己动手,丰衣足食啊。
找到twitter-tools.php文件中的:
define('AKTT_API_POST_STATUS', 'http://twitter.com/statuses/update.json'); define('AKTT_API_USER_TIMELINE', 'http://twitter.com/statuses/user_timeline.json'); define('AKTT_API_STATUS_SHOW', 'http://twitter.com/statuses/show/###ID###.json'); define('AKTT_PROFILE_URL', 'http://twitter.com/###USERNAME###'); define('AKTT_STATUS_URL', 'http://twitter.com/###USERNAME###/statuses/###STATUS###'); define('AKTT_HASHTAG_URL', 'http://search.twitter.com/search?q=###HASHTAG###'); |
用Twitter API proxy地址替换twitter.com即可。
我在GAE上搭建的Twitter API proxy可供大家免费无偿使用。
define('AKTT_API_POST_STATUS', 'http://anytwitter.appspot.com/api/statuses/update.json'); define('AKTT_API_USER_TIMELINE', 'http://anytwitter.appspot.com/api/statuses/user_timeline.json'); define('AKTT_API_STATUS_SHOW', 'http://anytwitter.appspot.com/api/statuses/show/###ID###.json'); define('AKTT_PROFILE_URL', 'http://anytwitter.appspot.com/api/###USERNAME###'); define('AKTT_STATUS_URL', 'http://anytwitter.appspot.com/api/###USERNAME###/statuses/###STATUS###'); define('AKTT_HASHTAG_URL', 'http://anytwitter.appspot.com/api/search?q=###HASHTAG###'); |
游戏-Cogs
by anyshpm on Feb.02, 2010, under 旅程
Cogs是Lazy 8 Studios制作的一款益智游戏,其官方称该游戏为革新的游戏。

Cogs主菜单
这就是一款拼图游戏,不过它是三维的。

Cogs游戏界面
可玩性还是不错的,我最近把它通关了。
有兴趣的同学可以前往Verycd寻找该款游戏。
《熊猫大侠》观后感
by anyshpm on Jan.23, 2010, under 旅程
看了一半,觉得这部电影特别乱,剧情像散沙,不连贯。看到后面才看出点味道。
电影以王老吉(刘烨饰)压镖为线索,看似描述了南宋年间的事,实质却是当代社会的缩影。反映了很多当今的一些现实问题,比如吃野生动物、官商勾结等。
电影的表现手法很是独特,人物语言幽默风趣。作为古装片,里面却有很多现代经典的话语。比如“女人的心,深不可测”、“我们这回是斩首行动,要的是精确打击”、“Happy一下”等等。
金莲(阿朵饰)还给我们阐述了一下该树立怎么样的爱情观。
王老吉的师傅说王老吉不是块当镖师的料,但王老吉凭借自己的信念和意志,最终完成了他人生的第一镖,最后大将军(任泉饰)赐其为熊猫大侠。
=================================== 图文分割线 ===================================
