2016-05-09 21 views
1

我想運行使用HWUT項目的文檔極簡主義迭代器示例,但在獲取以下錯誤。錯誤極簡主義迭代器示例HWUT

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

它是這個例子的代碼:

#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); 
     } 
    } 
} 

有人能告訴我是什麼問題? 而且這個項目還支持嗎?否則,有人可以推薦我一個更大的支持類似的項目?

非常感謝

回答

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); 
    } 
} 

而且,該項目仍然是活動的。

+0

雖然這可能是一個有價值的提示來解決問題,但答案確實需要證明解決方案。請[編輯]提供示例代碼來展示你的意思。或者,可以考慮將其寫爲註釋。 –