2016-05-09 6 views
1

Ich versuche, die Dokumentation minimalistischen Iterator-Beispiel mit dem HWUT-Projekt ausführen, aber die folgenden Fehler zu erhalten.Fehler Minimalist Iterator Beispiel 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 ':' 

Es ist der Code aus dem Beispiel:

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

Kann mir jemand sagen, was das Problem ist? Und wird dieses Projekt noch unterstützt? Kann mir sonst jemand ein ähnliches Projekt mit einer größeren Unterstützung empfehlen?

Vielen Dank

Antwort

0

Die Verteilung HWUT Quellcode enthält auf sich Unit-Test-Beispiele in den Test. Sie finden das minimalistische Iterator Beispiel in der Quellbaum von HWUT wie unten dargestellt:

Verzeichnis:

 $HWUT_PATH/hwut/code_generation/generator/TEST 

Datei:

 total.c 

Das heißt, der alle folgenden Syntax demonstriert wird definiert, Generatoren:

#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 

Ein üblicher Test wird etwas wie:

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

Und ja, das Projekt ist noch aktiv.

+0

Während dies ein wertvoller Hinweis sein könnte, um das Problem zu lösen, muss eine Antwort wirklich die Lösung demonstrieren. Bitte [bearbeiten], um Beispielcode anzugeben, um zu zeigen, was Sie meinen. Alternativ können Sie dies auch als Kommentar schreiben. –