码迷,mamicode.com
首页 >  
搜索关键字:assert    ( 2161个结果
strlen的三种实现方法,strcmp,strcat,strcpy
首先我们来看一下大家学习中经常熟悉用到的strlen函数。strlen1:指针差值返回intmy_strlen(constchar*str) { char*pst=(char*)str; assert(str); while(*str) { str++; } returnstr-pst; }strlen2:递归实现intmy_strlenT(constchar*str) { assert(str); if(*str) return1+my_..
分类:其他好文   时间:2015-09-19 19:48:53    阅读次数:326
junit4 测试异常
在某些情况下,我们断定目标方法会抛出异常,这时该如何处理呢。 ? ? 使用junit测试抛出的异常,我总结了3种方式,详见代码: import?static?org.junit.Assert.fail; import?org.junit.Rule; import?...
分类:其他好文   时间:2015-09-17 19:59:39    阅读次数:165
实现 标砖库中【strcpy】【strcmp】【strcat】
char*my_strcpy(char*arr,constchar*str) { char*pstr=arr; assert(arr!=NULL&&str!=NULL); while(*arr++=*str++) { ; } returnpstr; } #include<stdio.h> #include<stdlib.h> #include<assert.h> intmy_strcmp(constchar*str1,constcha..
分类:其他好文   时间:2015-09-17 15:31:54    阅读次数:106
JAVA保留字与关键字
Java 关键字列表 (依字母排序 共51组):abstract, assert,boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum,extends, fin...
分类:编程语言   时间:2015-09-17 11:47:41    阅读次数:212
iOS assert
assert 是C里面的宏。用于断言。assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调用 abort 来终止程序运行。NSAssert 只能在Objective-c里面使用。是assert的一个扩充。能捕获asser...
分类:移动开发   时间:2015-09-11 12:32:16    阅读次数:205
C++断言与静态断言
断言是很早之前就有的东西了,只需要引入cassert头文件即可使用。往往assert被用于检查不可能发生的行为,来确保开发者在调试阶段尽早发现“不可能”事件真的发生了,如果真的发生了,那么就表示代码的逻辑存在问题。最好的一点就是,断言只在Debug中生效,因此对于Release版本是没有效率上的.....
分类:编程语言   时间:2015-09-11 10:28:51    阅读次数:155
循环单链表
#include<iostream>#include<assert.h>typedefintDatatype;usingnamespacestd;structLinkNode{ Datatype_data; LinkNode*_next; LinkNode(constDatatype&x) :_data(x) ,_next(NULL) {}};classSlist{public: Slist() :_head(NULL) ,_tail(NULL) {} ~Slist()..
分类:其他好文   时间:2015-09-11 06:57:30    阅读次数:206
memcpy的初次认识与理解
#include<stdio.h>#include<assert.h>#include<stdlib.h>//模拟memcpyvoidmy_momcpy(char*dest,constchar*str,intcount){assert(dest!=NULL);assert(str!=NULL);char*ret=dest;inti=0;for(i=0;i<count;i++){*dest++=*str++;}}intmain(){chara[100]="abcde..
分类:其他好文   时间:2015-09-10 17:46:33    阅读次数:198
断言(ASSERT)的用法
我一直以为assert仅仅是个报错函数,事实上,它居然是个宏,并且作用并非“报错”。 在经过对其进行一定了解之后,对其作用及用法有了一定的了解,assert()的用法像是一种“契约式编程”,在我的理解中,其表达的意思就是,程序在我的假设条件下,能够正常良好的运作,其实就相当于一个if语句:1 ...
分类:其他好文   时间:2015-09-10 17:22:32    阅读次数:133
一个Java Dao测试用例
3 import static org.junit.Assert.assertTrue; 4 5 import java.util.Date; 6 import java.util.HashMap; 7 import java.util.List; 8 import java.uti...
分类:编程语言   时间:2015-09-09 11:27:19    阅读次数:275
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!