Skip to content

Commit c8d6b78

Browse files
committed
Add test for #180
1 parent a07ea16 commit c8d6b78

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BUG /tmp/test547238273/preproc/bug_callback.ino /^ public: BUG(void (*fn)(void)) {}$/;" kind:function line:6 class:BUG signature:(void (*fn)(void))
2+
b /tmp/test547238273/preproc/bug_callback.ino /^BUG b(makeItBreak); \/\/this will break$/;" kind:prototype line:10 signature:(makeItBreak)returntype:BUG
3+
setup /tmp/test547238273/preproc/bug_callback.ino /^void setup() {$/;" kind:function line:12 signature:() returntype:void
4+
loop /tmp/test547238273/preproc/bug_callback.ino /^void loop() {}$/;" kind:function line:16 signature:() returntype:void
5+
makeItBreak /tmp/test547238273/preproc/bug_callback.ino /^void makeItBreak() {}$/;" kind:function line:18 signature:() returntype:void
6+
caller /tmp/test547238273/preproc/bug_callback.ino /^void caller(int (*cc)(int ),int a) {$/;" kind:function line:20 signature:(int (*cc)(int ),int a) returntype:void
7+
blub /tmp/test547238273/preproc/bug_callback.ino /^int blub(int a) {$/;" kind:function line:24 signature:(int a) returntype:int

src/arduino.cc/builder/test/ctags_to_prototypes_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,33 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
443443
require.Equal(t, 2, ctx.PrototypesLineWhereToInsert)
444444
}
445445

446+
func TestCTagsToPrototypesFunctionPointersNoIndirect(t *testing.T) {
447+
ctx := &types.Context{}
448+
449+
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointersNoIndirect.txt"))
450+
NoError(t, err)
451+
452+
ctx.CTagsOutput = string(bytes)
453+
454+
commands := []types.Command{
455+
&ctags.CTagsParser{},
456+
&ctags.CTagsToPrototypes{},
457+
}
458+
459+
for _, command := range commands {
460+
err := command.Run(ctx)
461+
NoError(t, err)
462+
}
463+
464+
prototypes := ctx.Prototypes
465+
require.Equal(t, 5, len(prototypes))
466+
require.Equal(t, "void setup();", prototypes[0].Prototype)
467+
require.Equal(t, "/tmp/test547238273/preproc/bug_callback.ino", prototypes[0].File)
468+
require.Equal(t, "void loop();", prototypes[1].Prototype)
469+
470+
require.Equal(t, 10, ctx.PrototypesLineWhereToInsert)
471+
}
472+
446473
func TestCTagsRunnerSketchWithClassFunction(t *testing.T) {
447474
DownloadCoresAndToolsAndLibraries(t)
448475

0 commit comments

Comments
 (0)