我最近开始使用 FitNesse,并试图通过它为 C++ 代码创建验收测试。我最近下载了 CSlim,但似乎无法让示例装置工作。这是夹具代码的副本:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "SlimList.h"
#include "Fixtures.h"
class cMultiplication
{
public:
cMultiplication(){};
~cMultiplication(){};
float product()
{
return m1*m2;
}
float m1;
float m2;
char result[32];
};
#ifndef CPP_COMPILING
extern "C" {
#endif
typedef struct Multiplication
{
cMultiplication multiplication;
char result[32];
} Multiplication;
void* Multiplication_Create(StatementExecutor* errorHandler, SlimList* args)
{
Multiplication* self = (Multiplication*)malloc(sizeof(Multiplication));
self->result[0] = 0;
// self->multiplication = new cMultiplication();
return self;
}
void Multiplication_Destroy(void* void_self)
{
Multiplication* self = (Multiplication*)void_self;
// delete self->multiplication;
free(self);
}
static char* setMultiplicand1(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
self->multiplication.m1 = atof(SlimList_GetStringAt(args, 0));
return self->result;
}
static char* setMultiplicand2(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
self->multiplication.m2 = atof(SlimList_GetStringAt(args, 0));
return self->result;
}
static char* Product(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
float product = self->multiplication.product();
snprintf(self->result, 32, "%g", product);
return self->result;
}
SLIM_CREATE_FIXTURE(Multiplication)
SLIM_FUNCTION(setMultiplicand1)
SLIM_FUNCTION(setMultiplicand2)
SLIM_FUNCTION(Product)
SLIM_END
#ifndef CPP_COMPILING
}
#endif
我会感激你必须给我的任何帮助和智慧。
<code>!define TEST_SYSTEM {slim}
!path C:\Users\212411176\Documents\Git_Repositories\cslim-master\fixtures\
!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}
!|import|
|FixtureInCpp.cpp|
|cMultiplication|
|Multiplication1|Multiplication2|Product?|
|1|1|1|
|5|4|20|
|5|4|20|
提前感谢您能给我的任何见解。
干杯,
亚历山大