Skip to content

Commit 9e3000c

Browse files
committed
Add test for arduino#180
1 parent 9199e99 commit 9e3000c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

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

+27
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,33 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
209209
require.Equal(t, 2, line)
210210
}
211211

212+
func TestCTagsToPrototypesFunctionPointersNoIndirect(t *testing.T) {
213+
ctx := &types.Context{}
214+
215+
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointersNoIndirect.txt"))
216+
NoError(t, err)
217+
218+
ctx.CTagsOutput = string(bytes)
219+
220+
commands := []types.Command{
221+
&ctags.CTagsParser{},
222+
&ctags.CTagsToPrototypes{},
223+
}
224+
225+
for _, command := range commands {
226+
err := command.Run(ctx)
227+
NoError(t, err)
228+
}
229+
230+
prototypes := ctx.Prototypes
231+
require.Equal(t, 5, len(prototypes))
232+
require.Equal(t, "void setup();", prototypes[0].Prototype)
233+
require.Equal(t, "/tmp/test547238273/preproc/bug_callback.ino", prototypes[0].File)
234+
require.Equal(t, "void loop();", prototypes[1].Prototype)
235+
236+
require.Equal(t, 10, ctx.PrototypesLineWhereToInsert)
237+
}
238+
212239
func TestCTagsRunnerSketchWithClassFunction(t *testing.T) {
213240
prototypes, _ := producePrototypes(t, "TestCTagsRunnerSketchWithClassFunction.txt")
214241

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

0 commit comments

Comments
 (0)