- 博客(22)
- 资源 (7)
- 收藏
- 关注
转载 mockcpp高级指导
Default SpecificationDefault specification is defined by using defaults(), rather than expects()/stubs(). Relations between defaults() and expects()/stubs() could be thought as relations between default and case in C/C++ switch statements. If all specific
2021-08-24 23:35:19
846
翻译 mockcpp使用手册
1. 背景mock++是一个C/C++语言的mock框架。它最初出现的原因并不是为了重新发明轮子,也不是为了做Yet Another C++ mock framework。在mock++出现之前,在互联网上可以找到的C++ Mock框架只有mockpp; 在我们最初的敏捷开发实践中,它也就是我们唯一的选择。虽然mockpp 是一个优秀的框架,但它的实现使用了非常复杂的模版技术,这带来了漫长的编译时间,和非常晦涩难懂的编译错误信息。这对于TDD的步伐有着非常负面的影响。另外,mockpp所提供的功能在某些
2021-08-24 23:33:19
2799
翻译 mockcpp使用方法简明指导
mockcpp使用方法简明指导mock工具介绍mock工具的作用是指定函数的行为(模拟函数的行为)。可以对入参进行校验,对出参进行设定,还可以指定函数的返回值。几个相关概念(1)mock规范:每个MOCKER(function)开始,跟一系列的.stubs、.with、.will等的内容的整体,称为一个mock规范。(2)核心关键字:指stubs/defaults/expects/before/with/after/will/then/id等这些直接跟在点后面的关键字。(3)扩展关键字:指onc
2021-08-24 23:31:32
2551
翻译 Glib官方文档阅读 The Main Event Loop
头文件#include <glib.h>描述主事件循环管理GLib和GTK+应用程序的所有可用事件源。这些事件可以来自任何数量的不同类型来源,如文件描述符(普通文件、管道或套接字)和超时。也可以使用g_source_attach()添加新类型的事件源。为了允许在不同线程中处理多个独立的源集,每个源都与一个GMainContext相关联。一个GMainContext只能在单个线程中运行,但可以从其他线程将事件源加入或移除。所有在GMainContext或内置GSource上运行的函数都是
2021-06-20 22:34:19
339
转载 git自定义指令
alias gpm='git push origin master'alias ...=../..alias ....=../../..alias .....=../../../..alias ......=../../../../..alias 1='cd -'alias 2='cd -2'alias 3='cd -3'alias 4='cd -4'alias 5='cd -5'alias 6='cd -6'alias 7='cd -7'alias 8='cd -8'alias
2021-06-15 10:55:32
435
原创 词频统计程序C语言实现
词频统计程序C语言实现#include <stdio.h>#include <stdbool.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#define MAX_WORD_LEN (30)FILE * fdest;typedef struct { char word[MAX_WORD_LEN]; int count;} Item;typedef
2021-06-14 00:31:41
990
转载 如何定义自己的可变参函数-C语言实现
像标准C函数printf一样。一般这样声明:void func(char* form, ...);前面至少有一个确定的参数。函数体内如何获取这些参数呢?这就需要用到几个宏以及了解他们的原理。函数参数是以数据结构——栈的形式存取,从右至左入栈。因此,从理论上说,我们只要探测到任意一个变量的地址,并且知道其他变量的类型,通过指针移位运算,则总可以找到其他的变量。<stdarg.h> 中定义了几个重要的宏:typedef char* va_list;void va_start ( va
2021-06-09 15:44:03
274
原创 长度系统req8
#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>#define True 1#define False 0typedef enum { Mile = 0, Yard, Feet, Inch, MaxType}unit_e;typedef enum { hp = 0, lp}mode_e;extern un
2021-06-08 15:52:25
195
原创 C语言实现密码强度校验
#include <stdio.h>#include <stdlib.h>#include <string.h>int passwd_meter(const char *passwd) { //cycle val int i = 0; //1. passwd len unsigned int passwd_len; passwd_len = strlen(passwd); //2. capital and low
2021-06-07 22:51:06
780
转载 常量指针、指针常量以及指向常量的指针常量
三个名词虽然非常绕嘴,不过说的非常准确。用中国话的语义分析就可以很方便地把三个概念区分开。一)常量指针。常量是形容词,指针是名词,以指针为中心的一个偏正结构短语。这样看,常量指针本质是指针,常量修饰它,表示这个指针乃是一个指向常量的指针(变量)。指针指向的对象是常量,那么这个对象不能被更改。在C/C++中,常量指针是这样声明的:1)const int *p;2)int const *p;常量指针的使用要注意,指针指向的对象不能通过这个指针来修改,可是仍然可以通过原来的声明修改,也就是说常量指针
2021-06-07 08:38:34
671
1
转载 typedef函数指针
用途:函数指针通常用来实现回调,也可以用来对模块调用以函数表的形式进行优化。使用方法:1、定义函数指针类型使用typedef更直观更方便// 定义一个原型为int Fun( int a );的函数指针typedef int (*PTRFUN) ( int aPara );typedef的功能是定义新的类型。这里定义了一种PTRFUN的类型,并定义这种类型为指向某种函数的指针,这种函数以一个int为参数并返回char类型。后面就可以像使用int,char一样使用PTRFUN了。2、函数指针
2021-06-07 08:20:43
1439
原创 度量系统最终实现
#ifndef LIST_H_#define LIST_H_#include <stdio.h>#include <stdlib.h>#include <string.h>#define FAILURE (-1)#define SUCCESS (0)#define RETURN_V
2021-06-05 17:43:53
219
原创 长度系统req7
#ifndef LENGTH_H_#define LENGTH_H_#define True 0#define False 1struct list_head { struct list_head *next, *prev;};struct unit_t { char unit_name[16]; struct list_head list;};typedef struct { unsigned int value; int
2021-05-28 21:48:36
105
原创 长度系统req6
#ifndef LENGTH_H_#define LENGTH_H_#define True 0#define False 1typedef enum { TBSP = 0, TSP, OZ}unit_e;typedef struct{ unsigned int value; unit_e unit; unsigned int absolute; }Volume_t;#endif
2021-05-28 21:47:43
157
原创 长度系统req5
#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>#define True 0#define False 1typedef enum { Mile = 0, Yard, Feet, Inch, MaxType}unit_e;extern unsigned int dimension[MaxType];typedef stru
2021-05-28 21:46:55
92
原创 长度系统req4
#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>#define True 0#define False 1typedef enum { Mile = 0, Yard, Feet, Inch, MaxType}unit_e;extern unsigned int dimension[MaxType];typedef stru
2021-05-28 21:45:02
132
原创 长度系统req3
#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>#define True 0#define False 1typedef enum { Mile = 0, Yard, Feet, Inch, MaxType}unit_e;extern unsigned int dimension[MaxType];typedef stru
2021-05-28 21:44:02
156
原创 如何判断IP地址与子网掩码的合法性
如何判断IP地址与子网掩码的合法性#include <arpa/inet.h>#include <stdio.h>#include <string.h>int if_a_string_is_a_valid_ipv4_address(const char *str){ struct in_addr addr; int ret; volatile int local_errno; int errno = 0; ret =
2021-05-27 23:18:43
570
原创 req 2
#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>#define True 0#define False 1typedef enum { Mail = 0, Yard, MaxType}unit_e;extern unsigned int dimension[MaxType];typedef struct { unsigned in
2021-05-25 23:03:44
133
原创 req 1
//// req 1 Length.h//#ifndef LENGTH_H_#define LENGTH_H_#include <stdio.h>#include <stdlib.h>typedef int Mail;#define True 0#define False 1int LengthEqual(Mail len1, Mail len2);#endif////req 1 Length.c//#include "Length.h"
2021-05-25 23:02:06
236
原创 C语言实现长度库-面向对象设计模式
C语言实现长度库//// Length.h// Created by kori on 2021/5/24.//#ifndef LENGTH_LENGTH_H#define LENGTH_LENGTH_H/*## class Length */typedef enum { Mail = 0, Yard, Feet, Inch, UnitMax}length_unit_e;typedef enum { Greater = 0, E
2021-05-24 23:14:10
103
原创 eeprom页写策略
#include <stdio.h>#define MAX_PAGES 256#define PER_PAGE 32int page_write(int addr, int nbytes, char *buf){printf(“addr = %d, nbytes = %d-------”, addr, nbytes);}int random_write(int addr, char *buf, int size){int current_addr = addr;char *
2021-04-13 23:45:21
504
Manage C data using the GLib collections – IBM Developer.pdf
2021-08-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人