assert语句:用以检查某一条件是否为True,若该条件为False则会给出一个AssertionError。用法:assert type(x)=int and x>=0如果不满足后面的expression,则会弹出Traceback (most recent call last): File ....
分类:
编程语言 时间:
2014-09-15 19:16:59
阅读次数:
599
函数与方法、枚举等的书写格式与用法还是变化很大的。
一、函数
1.1 无返回值, 无形参
func myTest2(){
println("Hello")
}
1.2 有返回值,有形参
func myTest1( num1:Int , num2:Int ) -> String{
return String(num1 + num2)
}
1.3 外部参数. (相当于给...
分类:
移动开发 时间:
2014-09-15 04:32:08
阅读次数:
319
assert宏的原型定义在中,其作用是如果它的条件返回错误,则终止程序执行,原型定义:#include void assert( int expression ); assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调....
分类:
其他好文 时间:
2014-09-14 16:33:47
阅读次数:
353
核心断言 assertArrayEquals(expecteds, actuals) 查看两个数组是否相等。 assertEquals(expected, actual) 查看两个对象是否相等。类似于字符串比较使用的equals()方法 assertNotEquals(first, second) ...
分类:
其他好文 时间:
2014-09-12 22:04:14
阅读次数:
339
前言 cakephp 的单元测试参考http://book.cakephp.org/2.0/en/development/testing.html以下是CakeTestCase类的断言,也就是cakephp 定义的断言,实际使用中还可以使用CakeTestCase的父类PHPUnit_Framewo...
分类:
Web程序 时间:
2014-09-12 20:36:44
阅读次数:
220
boost的静态断言可以实现在编译器就检测错误的类型或语法...
分类:
其他好文 时间:
2014-09-11 12:35:31
阅读次数:
142
1?junit测试用例代码 package?junitTest;
import?static?org.junit.Assert.*;
import?org.junit.After;
import?org.junit.AfterClass;
import?org.junit.Before;
import?org.junit.BeforeClass;
import...
分类:
其他好文 时间:
2014-09-11 11:26:32
阅读次数:
196
当创建单元测试时,Microsoft.VisualStudio.TestTools.UnitTesting的名字控件会添加到测试项目中,该名字控件中包含很多有用的类: 断言类:在单元测试中验证条件 初始化 和 清理特性: 用于在单元测试运行之前和之后运行代码,以确保特定的开始和结束状 Expecte...
分类:
其他好文 时间:
2014-09-10 22:16:41
阅读次数:
215
1、strcpy
2、strcmp
int strcmp(const char* str1,const char* str2)
{
assert(str1!=NULL && str2!=NULL);
while(*str1 && *str2 && *str1 == *str2)
{
str1++;
str2++;
}
int res = *str1 - *str2;
if(...
分类:
其他好文 时间:
2014-09-09 13:03:18
阅读次数:
200