0

我最近开始使用 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|

提前感谢您能给我的任何见解。

干杯,

亚历山大

4

1 回答 1

0

夹具需要更新,请尝试以下夹具

!define TEST_SYSTEM {slim} 
!define TEST_RUNNER {PATH_TO_CSlim}
!define COMMAND_PATTERN {%m} 
!define SLIM_VERSION {0.0} 

!|import|
|FixtureInCpp.cpp|

|Multiplication| |Multiplicand1|Multiplicand2|产品?| |1|1|1| |5|4|20| |5|4|20|

于 2014-11-26T04:45:45.030 回答