C/C++
Unit Test Frameworks
先收集一些,再作比较测试Tips
千万不要用strcpy
这个东西就应该被扔到异次元空间被粉碎一万遍,所有str开头的函数只要有strn的版本都应该用strn的版本(strcmp和stricmp除外),buffer overflow是万恶之源注意分配和释放资源
open()和close(), malloc()和free(), connect()和close()要成对出现,防止导致资源泄露。程序crash的返回值
程序crash以后的返回值的低8位是0, 既可以用int retValue; retValue = system("./a.out"); if ( !retValue && ! (retValue && 127)) { /* Oh, my god, the ./a.out is crashed...*/ }