Error Minimalist Iterator示例HWUT

时间:2016-05-09 12:17:23

标签: c unit-testing

我正在尝试使用HWUT项目运行文档minimalist iterator示例,但是我收到以下错误。

    Sub BasicCalendar()
         dateVariable = CalendarForm.GetDate
          If dateVariable <> 0 Then Range("H16") = dateVariable
     End Sub

这是示例中的代码:

C:\hwut\demo\c\iterator\TEST>hwut gen test-it.c
Error: maker '<<hwut-file: ...>>' is ignored since version 0.20.4.
Error: use '-o file-stem' on command line instead.
Error: missing closing '|' for range. found ':'

有人可以告诉我这是什么问题吗? 这项目仍然受到支持吗?否则,有人会推荐我一个有更大支持的类似项目吗?

非常感谢

1 个答案:

答案 0 :(得分:0)

HWUT源代码分发包含单元测试示例 对自己的考验。您可以在中找到极简主义迭代器示例 HWUT的源树如下所示:

目录:

     $HWUT_PATH/hwut/code_generation/generator/TEST

文件:

     total.c

即,以下演示了用于定义生成器的所有语法:

#if 0 
<<hwut-iterator:  myGen1>> 
------------------------------------------------------------------------
#include <stdint.h>
------------------------------------------------------------------------
    int x;    float y;   char* str;       uint32_t array;  float farray;

## Plain constants
        1;        2.0;         "a";        { 1, 2, 3, 4};     {1.0,1.1};
        2;        2.1;         "b";           { 1, 2, 3};     {2.0,1.2};
        3;        2.2;         "c";              { 1, 2};     {3.0,1.3};
        4;        2.3;         "d";                 { 1};     {4.0,1.4};

------------------------------------------------------------------------

<<hwut-iterator: myGen2>> 
------------------------------------------------------------------------
#include <stdint.h>
------------------------------------------------------------------------
    int x;    float y;   char* str;       uint32_t array;  float farray;

## Selections
   [0, 1];        2.4;         "e";              { 1, 2};               {1.5};
        5; [7.1, 7.2];         "f";           { 1, 2, 3};               {1.5};
        6;        2.5;  ["X", "Y"];        { 1, 2, 3, 4};               {1.5};
        7;        2.6;         "i";     [{5, 6}, {7, 8}];               {1.5};
        8;        2.7;         "j";                 { 1};  [{6.0,6.1}, {7.0,7.1}];

------------------------------------------------------------------------

<<hwut-iterator: myGen3>> 
------------------------------------------------------------------------
#include <stdint.h>
------------------------------------------------------------------------
        int x;                  float y;   
## Ranges
        |0:5|;                     -2.0; 
|5:10| step 2;                     -1.0;
           11;                |0.0:5.0|;
           12;       |5.0:7.0| step 0.5;

------------------------------------------------------------------------

<<hwut-iterator: myGen4>> 
------------------------------------------------------------------------
#include <stdint.h>
------------------------------------------------------------------------
        int x;                        float y;   

## Focus Ranges                 
      1000;                             |x-1:x+1|;
       100;                             |x-3:x+3|;
        99;                                 |x:x|;
        10;              |x-0.5:x+1.25| step 0.25;
         0;      |x-3:x+1.5| in |-1.5:2| step 1.5;
------------------------------------------------------------------------
#endif

通常的测试类似于:

#include <hwut_unit.h>

void              
main(int argc, char** argv)
{
    hwut_info("This is a simple test;");

    myGen4_t       it;
    classUnderTest obj;

    myGen4_init(&it);

    while( myGen4_next(&it) ) {
        setup(&obj, &it);

        obj.memberFunction(it->some_arg, it->another_arg);

        check(&obj, it->some_parameters);
    }
}

而且,是的,该项目仍然有效。