Skip to content

Commit 801421f

Browse files
test: add mixed test-direction test
1 parent 9f78157 commit 801421f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

deepl-java/src/test/java/com/deepl/api/GeneralTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ void testInvalidServerUrl() {
5959
});
6060
}
6161

62+
@Test
63+
void testMixedDirectionText() throws DeepLException, InterruptedException {
64+
Assumptions.assumeFalse(isMockServer);
65+
Translator translator = createTranslator();
66+
TextTranslationOptions options =
67+
new TextTranslationOptions().setTagHandling("xml").setIgnoreTags(Arrays.asList("xml"));
68+
String arIgnorePart = "<ignore>يجب تجاهل هذا الجزء.</ignore>";
69+
String enSentenceWithArIgnorePart =
70+
"<p>This is a <b>short</b> <i>sentence</i>. " + arIgnorePart + " This is another sentence.";
71+
String enIgnorePart = "<ignore>This part should be ignored.</ignore>";
72+
String arSentenceWithEnIgnorePart =
73+
"<p>هذه <i>جملة</i> <b>قصيرة</b>. " + enIgnorePart + "هذه جملة أخرى.</p>";
74+
75+
TextResult enResult =
76+
translator.translateText(enSentenceWithArIgnorePart, null, "en-US", options);
77+
Assertions.assertTrue(enResult.getText().contains(arIgnorePart));
78+
TextResult arResult = translator.translateText(arSentenceWithEnIgnorePart, null, "ar", options);
79+
Assertions.assertTrue(arResult.getText().contains(enIgnorePart));
80+
}
81+
6282
@Test
6383
void testUsage() throws DeepLException, InterruptedException {
6484
Translator translator = createTranslator();

0 commit comments

Comments
 (0)