Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e35aa9

Browse files
committed
Add test for #292
1 parent f9d69df commit 2e35aa9

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

‎test/prototypes_adder_test.go‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
package test
3232

3333
import (
34-
"github.com/arduino/arduino-builder"
35-
"github.com/arduino/arduino-builder/types"
36-
"github.com/arduino/arduino-builder/utils"
37-
"github.com/stretchr/testify/require"
3834
"os"
3935
"path/filepath"
4036
"strings"
4137
"testing"
38+
39+
"github.com/arduino/arduino-builder"
40+
"github.com/arduino/arduino-builder/types"
41+
"github.com/arduino/arduino-builder/utils"
42+
"github.com/stretchr/testify/require"
4243
)
4344

4445
func TestPrototypesAdderBridgeExample(t *testing.T) {
@@ -906,3 +907,45 @@ func TestPrototypesAdderSketchWithDosEol(t *testing.T) {
906907
}
907908
// only requires no error as result
908909
}
910+
911+
func TestPrototypesAdderSketchWithSubstringFunctionMember(t *testing.T) {
912+
DownloadCoresAndToolsAndLibraries(t)
913+
914+
sketchLocation := filepath.Join("sketch_with_class_and_method_substring", "sketch_with_class_and_method_substring.ino")
915+
quotedSketchLocation := utils.QuoteCppString(Abs(t, sketchLocation))
916+
917+
ctx := &types.Context{
918+
HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"},
919+
ToolsFolders: []string{"downloaded_tools"},
920+
BuiltInLibrariesFolders: []string{"downloaded_libraries"},
921+
OtherLibrariesFolders: []string{"libraries"},
922+
SketchLocation: sketchLocation,
923+
FQBN: "arduino:avr:uno",
924+
ArduinoAPIVersion: "10600",
925+
Verbose: true,
926+
}
927+
928+
buildPath := SetupBuildPath(t, ctx)
929+
defer os.RemoveAll(buildPath)
930+
931+
commands := []types.Command{
932+
933+
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
934+
935+
&builder.ContainerMergeCopySketchFiles{},
936+
937+
&builder.ContainerFindIncludes{},
938+
939+
&builder.PrintUsedLibrariesIfVerbose{},
940+
&builder.WarnAboutArchIncompatibleLibraries{},
941+
942+
&builder.ContainerAddPrototypes{},
943+
}
944+
945+
for _, command := range commands {
946+
err := command.Run(ctx)
947+
NoError(t, err)
948+
}
949+
950+
require.Contains(t, ctx.Source, "class Foo {\nint blooper(int x) { return x+1; }\n};\n\nFoo foo;\n\n#line 7 "+quotedSketchLocation+"\nvoid setup();")
951+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Foo {
2+
int blooper(int x) { return x+1; }
3+
};
4+
5+
Foo foo;
6+
7+
void setup() {
8+
foo.setup();
9+
}
10+
11+
void loop() {
12+
foo.loop();
13+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /