-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure convert directory appears in Dirs
This is attempting to track down a bug where convert.h isn't generated properly in some cases. Sadly, this test passes, so it isn't caused by a missing directory.
- Loading branch information
1 parent
798578b
commit a10b169
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cpp_test | ||
|
||
import ( | ||
"path/filepath" | ||
"reflect" | ||
"sort" | ||
"testing" | ||
|
||
cfg "github.com/UoY-RoboStar/rtcg/internal/gen/config/cpp" | ||
"github.com/UoY-RoboStar/rtcg/internal/gen/cpp" | ||
"github.com/UoY-RoboStar/rtcg/internal/gen/gencommon" | ||
"github.com/UoY-RoboStar/rtcg/internal/stm" | ||
) | ||
|
||
// TestOnSuite_Dirs tests the Dirs method of OnSuite. | ||
func TestOnSuite_Dirs(t *testing.T) { | ||
t.Parallel() | ||
|
||
rtcgConvertDir := filepath.Join("out", "src", "convert") | ||
rtcgSrcDir := filepath.Join("out", "src", "rtcg") | ||
|
||
for name, input := range map[string]struct { | ||
config *cfg.Config | ||
want []string | ||
}{ | ||
"empty-animate": { | ||
config: cfg.New(cfg.VariantAnimate), | ||
want: []string{rtcgSrcDir}, | ||
}, | ||
"empty-animate-convert": { | ||
config: cfg.New(cfg.VariantAnimate, cfg.WithChannel("foo", "bar")), | ||
want: []string{rtcgConvertDir, rtcgSrcDir}, | ||
}, | ||
// TODO: add tests for non-empty cases | ||
} { | ||
config := input.config | ||
want := input.want | ||
|
||
t.Run(name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
dirs := gencommon.DirSet{Input: "in", Output: "out"} | ||
|
||
gen, err := cpp.New(config, dirs) | ||
if err != nil { | ||
t.Fatalf("unexpected error creating generator: %s", err) | ||
} | ||
|
||
var suite stm.Suite | ||
onSuite := gen.OnSuite(&suite) | ||
|
||
got := onSuite.Dirs() | ||
|
||
sort.Strings(got) | ||
sort.Strings(want) | ||
|
||
if !reflect.DeepEqual(got, want) { | ||
t.Errorf("unexpected directories: got %v, want %v", got, want) | ||
} | ||
}) | ||
} | ||
} |