@@ -370,7 +370,12 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
370370 }
371371
372372 preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch8" , "SketchWithStruct.preprocessed.txt" ), context )
373- require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
373+ obtained := strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 )
374+ // ctags based preprocessing removes the space after "dostuff", but this is still OK
375+ // TODO: remove this exception when moving to a more powerful parser
376+ preprocessed = strings .Replace (preprocessed , "void dostuff (A_NEW_TYPE * bar);" , "void dostuff(A_NEW_TYPE * bar);" , 1 )
377+ obtained = strings .Replace (obtained , "void dostuff (A_NEW_TYPE * bar);" , "void dostuff(A_NEW_TYPE * bar);" , 1 )
378+ require .Equal (t , preprocessed , obtained )
374379}
375380
376381func TestPrototypesAdderSketchWithConfig (t * testing.T ) {
@@ -587,7 +592,18 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
587592 }
588593
589594 require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
590- require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n short unsigned int testInt();\n #line 8 \" " + absoluteSketchLocation + "\" \n static int8_t testInline();\n #line 12 \" " + absoluteSketchLocation + "\" \n uint8_t testAttribute();\n #line 1\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
595+
596+ expected := "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n short unsigned int testInt();\n #line 8 \" " + absoluteSketchLocation + "\" \n static int8_t testInline();\n #line 12 \" " + absoluteSketchLocation + "\" \n __attribute__((always_inline)) uint8_t testAttribute();\n #line 1\n "
597+ obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
598+ // ctags based preprocessing removes "inline" but this is still OK
599+ // TODO: remove this exception when moving to a more powerful parser
600+ expected = strings .Replace (expected , "static inline int8_t testInline();" , "static int8_t testInline();" , - 1 )
601+ obtained = strings .Replace (obtained , "static inline int8_t testInline();" , "static int8_t testInline();" , - 1 )
602+ // ctags based preprocessing removes "__attribute__ ....." but this is still OK
603+ // TODO: remove this exception when moving to a more powerful parser
604+ expected = strings .Replace (expected , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
605+ obtained = strings .Replace (obtained , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
606+ require .Equal (t , expected , obtained )
591607}
592608
593609func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF (t * testing.T ) {
@@ -718,7 +734,13 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
718734 }
719735
720736 require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
721- require .Equal (t , "#line 6 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 10 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 6\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
737+ expected := "#line 6 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 10 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n #line 6\n "
738+ obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
739+ // ctags based preprocessing ignores line with typename
740+ // TODO: remove this exception when moving to a more powerful parser
741+ expected = strings .Replace (expected , "#line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n " , "" , - 1 )
742+ obtained = strings .Replace (obtained , "#line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n " , "" , - 1 )
743+ require .Equal (t , expected , obtained )
722744}
723745
724746func TestPrototypesAdderSketchWithIfDef2 (t * testing.T ) {
0 commit comments