CPPUTest?????????
???????????? ???????[ 2014/10/24 11:16:35 ] ??????????????? ???????
????CPPUTest ???????????????? C++ ????????????? ?????????????? C ?????.
?????????????????CPPUTest?????? C ????. (C++??ù??? ??????????C) C++??????????????.
??????????? debian v7.6 x86_64.
????1. CPPUTest ???
???????????Linux????а??????з??????????? ??????????.
?????????????????????????°汾????????? ??????????.
????debian?????????????? apt??е???????????. ????????е????????????????CPPUTest.
????1.1 apt-get ???
????$ sudo apt-get install cpputest
????1.2 ????
????1. ??????? ????: http://cpputest.github.io/
????2. ???????
????$ tar zxvf cpputest-3.6.tar.gz
????$ cd cpputest-3.6/
????$ ./configure
????$ make
?????????????????? ??????????????????????
????2. CPPUTest ????
????2.1 ???????????? (C????)
/* file: sample.h */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Student
{
char* name;
int score;
};
void ret_void(void);
int ret_int(int?? int);
double ret_double(double?? double);
char* ret_pchar(char*?? char*);
struct Student* init_student(struct Student* s?? char* name?? int score);
/* file: sample.c */
#include "sample.h"
#ifndef CPPUTEST
int main(int argc?? char *argv[])
{
char* pa;
char* pb;
pa = (char*) malloc(sizeof(char) * 80);
pb = (char*) malloc(sizeof(char) * 20);
strcpy(pa?? "abcdefg