c-如何处理HWUT中迭代器的极简主义示例中的错误



我正试图使用HWUT项目运行文档最小迭代器示例,但在中遇到了以下错误。

C:hwutdemociteratorTEST>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 ':'

这是示例中的代码:

#if 0
<<hwut-iterator:  myIterator>>
<<hwut-file:      myIterator>>
------------------------------------------------------------------------
#include <stdint.h>
------------------------------------------------------------------------
    int Case;    int x;    int y;
    0;  |1:9:2|;  |1:9:2|;
    1; |0:10:2|;   |0:10|;
------------------------------------------------------------------------
#endif
#include "hwut_unit.h"
#include "myIterator.h"
int main(int argc, char** argv)
{
    myIterator_t it;
hwut_info("Check product of even and odd;");
myIterator_init(&it);
while( myIterator_next(&it) ) {
    if( it->Case == 0 ) {
       // Odd x Odd == Odd
       assert( my_product(it->x, it->y) % 2 != 0 );
    } else if( it->Case == 0 ) {
       // Even x Anything == Even
       assert( my_product(it->x, it->y) % 2 == 0 );
       assert( my_product(it->y, it->x) % 2 == 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);
    }
}

是的,这个项目仍然在进行中。

相关内容

最新更新