2013年11月3日

摘要: 《将博客搬至CSDN》 阅读全文
posted @ 2013-11-03 14:23 ArcherXu 阅读(125) 评论(0) 推荐(0) 编辑

2013年3月31日

摘要: 以前在学谢希仁教授主编的《计算机网络》时,一直没弄懂IP首部的校验和是如何计算的。今天在看《TCP/IP详解 卷一》时,看到了一段关于首部校验和的描述。如下:为了计算一份数据报的IP校验和,首先把检验和的字段设置为0。然后,对首部中每个16bit进行二进制反码求和(整个首部看成是由一串16bit的字组成),结果存在校验和字段中。当收到一份IP数据报后,同样对首部中每16bit进行二进制反码求和。由于接收方在计算过程中包含了发送方存在首部中的检验和,因此,如果首部在传输过程中没有发生任何差错,那么接收方计算的结果应该全为1。如果结果不是全1,即检验和错误。通过Wireshark抓到一个IP数据包 阅读全文
posted @ 2013-03-31 13:00 ArcherXu 阅读(2092) 评论(0) 推荐(0) 编辑

2012年12月14日

摘要: 一直在用SVN管理代码,用的很舒服。但并没有意识到版本管理的重要性,昨天深有体会。佛语说:顿悟。调试一个项目,这个项目依赖于另一个老版本的lib,现在lib又有了好多新版本。但是从lib的代码看不出是什么版本,且新版与旧版接口部分不兼容。最终出现的问题是:不知道这个项目到底用哪个版本的lib。整了半天,无比郁闷。以后要注意的地方:1, 版本管理工具很重要。2,如果是一个exe,一定要提供命令行查看当前版本。如 xx.exe -version3,在自已的源代码中,定义一个全局的变量GLOBAL_PROJECTNAME_VERSION=xxxx 或 提供源码的修改日期。 阅读全文
posted @ 2012-12-14 12:40 ArcherXu 阅读(651) 评论(0) 推荐(0) 编辑

2012年12月13日

摘要: Python内建函数type(object),用于返回当前object对象的类型。例如:>>> type(1)<type 'int'>>>> type("1")<type 'str'>types模块定义了python中所有的类型,包括NoneType, TypeType, ObjectType....types模块所在的位置为{%PYTHONPATH%\lib\types.py}.实现方法很简单,把对应的类型赋值给变量:NoneType = type(None)TypeType = 阅读全文
posted @ 2012-12-13 20:14 ArcherXu 阅读(4668) 评论(0) 推荐(0) 编辑

2012年12月12日

摘要: Nahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited person to determine the size of the piece of cake that he/she wants (which should also be square-shaped). 阅读全文
posted @ 2012-12-12 10:18 ArcherXu 阅读(293) 评论(0) 推荐(0) 编辑

2012年12月8日

摘要: 参数化测试or数据驱动可以利用大量的数据跑一个具体的Case,有利于发现问题。至于Google test如何写数据驱动,请参考google的文档。先介绍求Prime素数的类:// The prime table interface.class PrimeTable { public: virtual ~PrimeTable() {} // Returns true iff n is a prime number. virtual bool IsPrime(int n) const = 0; // Returns the smallest prime number greater tha... 阅读全文
posted @ 2012-12-08 10:50 ArcherXu 阅读(786) 评论(0) 推荐(0) 编辑

2012年12月7日

摘要: 我采用的测试代码如下:#include <iostream>#include "gtest.h"TEST(SimpleTest, Test1){ EXPECT_TRUE(1);}TEST(SimpleTest, Test2){ EXPECT_TRUE(2);}class FooTest : public ::testing::Test {protected: static void SetUpTestCase() { shared_resource_ = new char[1024]; } static void TearDownTestCase()... 阅读全文
posted @ 2012-12-07 21:14 ArcherXu 阅读(1530) 评论(0) 推荐(0) 编辑

2012年11月23日

摘要: //asyncTest, QUnit中的异步测试,具体参考QUnit官方文档。//直接上代码//step 1: write a simple asyncTest as the following.asyncTest("asynchronous test: one second later!", function() { expect(1); setTimeout(function() { ok(true, "Passed and ready to resume!"); start(); }, 1000);});//step 2: 调用test函数Q... 阅读全文
posted @ 2012-11-23 14:09 ArcherXu 阅读(557) 评论(0) 推荐(0) 编辑
摘要: // 直接上代码//step 1: write a simple test as the following.test("hello test", function() { ok(1 == "1", "Passed!");});//step 2: 调用test函数QUnit = { //... test : function(testName, expected, callback, async) { //... //初始化test, test = new Test({ name : name, ... 阅读全文
posted @ 2012-11-23 14:07 ArcherXu 阅读(298) 评论(0) 推荐(0) 编辑

2012年11月21日

摘要: 8 定制new和delete条款49:了解new-handler的行为new_handler set_new_handler (new_handler new_p) throw();Sets new_p as the new handler function, the old one is returned.operator new抛出异常以反映一个未获满足的内存需求之前,它会先调用一个客户指定的错误处理函数,客户必须调用set_new_handler设定。class NewHandlerHolder{explicit NewHandlerHolder (std::new_handler nh 阅读全文
posted @ 2012-11-21 22:43 ArcherXu 阅读(185) 评论(0) 推荐(0) 编辑

导航