-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from DIMO-Network/feature/si-2686-handle-acron…
…ym-casing-in-signal-names Update JSON name creation
- Loading branch information
Showing
8 changed files
with
132 additions
and
50 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
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,56 @@ | ||
package schema | ||
|
||
import "testing" | ||
|
||
func TestJSONName(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expected string | ||
}{ | ||
{ | ||
input: "Vehicle.CurrentLocation.Altitude", | ||
expected: "currentLocationAltitude", | ||
}, | ||
{ | ||
input: "Vechicle.DIMO.Source", | ||
expected: "dimoSource", | ||
}, | ||
{ | ||
input: "Vehicle.DIMO.WPAState", | ||
expected: "dimoWPAState", | ||
}, | ||
{ | ||
input: "Vehicle.DIMO.Aftemarket.HDOP", | ||
expected: "dimoAftemarketHDOP", | ||
}, | ||
{ | ||
input: "Vehicle.DIMO.Aftemarket.WPAState", | ||
expected: "dimoAftemarketWPAState", | ||
}, | ||
{ | ||
input: "Vehicle.Powertrain.CombustionEngine.ECT", //nolint:misspell // ECT is an abbreviation | ||
expected: "powertrainCombustionEngineECT", | ||
}, | ||
{ | ||
input: "Vehicle.Powertrain.CombustionEngine.Tps", | ||
expected: "powertrainCombustionEngineTps", | ||
}, | ||
{ | ||
input: "", | ||
expected: "", | ||
}, | ||
{ | ||
input: "Vehicle", | ||
expected: "vehicle", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.input, func(t *testing.T) { | ||
result := jsonName(test.input) | ||
if result != test.expected { | ||
t.Errorf("Unexpected result. Expected: %s, Got: %s", test.expected, result) | ||
} | ||
}) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.