-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support option: translate text API: formality #1
- Loading branch information
Showing
4 changed files
with
201 additions
and
7 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
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,137 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/michimani/deepl-sdk-go/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSplitSentencesValid(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
s types.SplitSentences | ||
exect bool | ||
}{ | ||
{ | ||
name: "SplitSentencesNoSplit", | ||
s: types.SplitSentencesNoSplit, | ||
exect: true, | ||
}, | ||
{ | ||
name: "SplitSentencesSplit", | ||
s: types.SplitSentencesSplit, | ||
exect: true, | ||
}, | ||
{ | ||
name: "SplitSentencesNoNewLines", | ||
s: types.SplitSentencesNoNewLines, | ||
exect: true, | ||
}, | ||
{ | ||
name: "invalid value", | ||
s: types.SplitSentences("invalid value"), | ||
exect: false, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(tt *testing.T) { | ||
b := c.s.Valid() | ||
|
||
assert.Equal(tt, b, c.exect) | ||
}) | ||
} | ||
} | ||
|
||
func TestPreserveFormattingValid(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
s types.PreserveFormatting | ||
exect bool | ||
}{ | ||
{ | ||
name: "PreserveFormattingDisabled", | ||
s: types.PreserveFormattingDisabled, | ||
exect: true, | ||
}, | ||
{ | ||
name: "PreserveFormattingEnabled", | ||
s: types.PreserveFormattingEnabled, | ||
exect: true, | ||
}, | ||
{ | ||
name: "invalid value", | ||
s: types.PreserveFormatting("invalid value"), | ||
exect: false, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(tt *testing.T) { | ||
b := c.s.Valid() | ||
|
||
assert.Equal(tt, b, c.exect) | ||
}) | ||
} | ||
} | ||
|
||
func TestFormalityValid(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
s types.Formality | ||
l types.TargetLangCode | ||
exect bool | ||
}{ | ||
{ | ||
name: "FormalityDefault", | ||
s: types.FormalityDefault, | ||
l: types.TargetLangRU, | ||
exect: true, | ||
}, | ||
{ | ||
name: "FormalityMore", | ||
s: types.FormalityMore, | ||
l: types.TargetLangRU, | ||
exect: true, | ||
}, | ||
{ | ||
name: "FormalityLess", | ||
s: types.FormalityLess, | ||
l: types.TargetLangRU, | ||
exect: true, | ||
}, | ||
{ | ||
name: "invalid value", | ||
s: types.Formality("invalid value"), | ||
l: types.TargetLangRU, | ||
exect: false, | ||
}, | ||
{ | ||
name: "FormalityDefault with not supported target language", | ||
s: types.FormalityDefault, | ||
l: types.TargetLangJA, | ||
exect: false, | ||
}, | ||
{ | ||
name: "FormalityMore with not supported target language", | ||
s: types.FormalityMore, | ||
l: types.TargetLangJA, | ||
exect: false, | ||
}, | ||
{ | ||
name: "FormalityLess with not supported target language", | ||
s: types.FormalityLess, | ||
l: types.TargetLangJA, | ||
exect: false, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(tt *testing.T) { | ||
b := c.s.Valid(c.l) | ||
|
||
assert.Equal(tt, b, c.exect) | ||
}) | ||
} | ||
} |