SQL: skip uppercasing/lowercasing function tests for AZ locales as well (#32910)

* Added the rest of the Locales that have different behavior for uppercasing/lowercasing scenarios to the skip list
This commit is contained in:
Andrei Stefan 2018-08-23 00:21:38 +03:00 committed by GitHub
parent edd477a15e
commit de95dead2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 20 deletions

View File

@ -75,10 +75,12 @@ public class StringFunctionProcessorTests extends AbstractWireSerializingTestCas
stringCharInputValidation(proc); stringCharInputValidation(proc);
} }
public void testLCaseWithTRLocale() { public void testLCaseWithAZTRLocale() {
Locale initialLocale = Locale.getDefault();
Locale.setDefault(Locale.forLanguageTag("tr")); Locale.setDefault(Locale.forLanguageTag("tr"));
StringProcessor proc = new StringProcessor(StringOperation.LCASE);
try {
StringProcessor proc = new StringProcessor(StringOperation.LCASE);
// ES-SQL is not locale sensitive (so far). The obvious test for this is the Turkish language, uppercase letter I conversion // ES-SQL is not locale sensitive (so far). The obvious test for this is the Turkish language, uppercase letter I conversion
// in non-Turkish locale the lowercasing would create i and an additional dot, while in Turkish Locale it would only create "i" // in non-Turkish locale the lowercasing would create i and an additional dot, while in Turkish Locale it would only create "i"
// unicode 0069 = i // unicode 0069 = i
@ -86,6 +88,14 @@ public class StringFunctionProcessorTests extends AbstractWireSerializingTestCas
// unicode 0049 = I (regular capital letter i) // unicode 0049 = I (regular capital letter i)
// in Turkish locale this would be lowercased to a "i" without dot (unicode 0131) // in Turkish locale this would be lowercased to a "i" without dot (unicode 0131)
assertEquals("\u0069", proc.process("\u0049")); assertEquals("\u0069", proc.process("\u0049"));
Locale.setDefault(Locale.forLanguageTag("az"));
assertEquals("\u0069\u0307", proc.process("\u0130"));
assertEquals("\u0069", proc.process("\u0049"));
} finally {
// restore the original Locale
Locale.setDefault(initialLocale);
}
} }
public void testUCase() { public void testUCase() {
@ -102,13 +112,22 @@ public class StringFunctionProcessorTests extends AbstractWireSerializingTestCas
stringCharInputValidation(proc); stringCharInputValidation(proc);
} }
public void testUCaseWithTRLocale() { public void testUCaseWithAZTRLocale() {
Locale initialLocale = Locale.getDefault();
Locale.setDefault(Locale.forLanguageTag("tr")); Locale.setDefault(Locale.forLanguageTag("tr"));
StringProcessor proc = new StringProcessor(StringOperation.UCASE);
try {
StringProcessor proc = new StringProcessor(StringOperation.UCASE);
// ES-SQL is not Locale sensitive (so far). // ES-SQL is not Locale sensitive (so far).
// in Turkish locale, small letter "i" is uppercased to "I" with a dot above (unicode 130), otherwise in "i" (unicode 49) // in Turkish locale, small letter "i" is uppercased to "I" with a dot above (unicode 130), otherwise in "i" (unicode 49)
assertEquals("\u0049", proc.process("\u0069")); assertEquals("\u0049", proc.process("\u0069"));
Locale.setDefault(Locale.forLanguageTag("az"));
assertEquals("\u0049", proc.process("\u0069"));
} finally {
// restore the original Locale
Locale.setDefault(initialLocale);
}
} }
public void testLength() { public void testLength() {
@ -179,7 +198,7 @@ public class StringFunctionProcessorTests extends AbstractWireSerializingTestCas
assertEquals(7, proc.process("foo bar")); assertEquals(7, proc.process("foo bar"));
assertEquals(0, proc.process("")); assertEquals(0, proc.process(""));
assertEquals(1, proc.process('f')); assertEquals(1, proc.process('f'));
assertEquals(1, proc.process('€')); assertEquals(1, proc.process('\u20ac')); // euro symbol
stringCharInputValidation(proc); stringCharInputValidation(proc);
} }

View File

@ -13,6 +13,7 @@ import org.junit.ClassRule;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -37,8 +38,7 @@ public abstract class SqlSpecTestCase extends SpecBaseIntegrationTestCase {
tests.addAll(readScriptSpec("/agg.sql-spec", parser)); tests.addAll(readScriptSpec("/agg.sql-spec", parser));
tests.addAll(readScriptSpec("/arithmetic.sql-spec", parser)); tests.addAll(readScriptSpec("/arithmetic.sql-spec", parser));
tests.addAll(readScriptSpec("/string-functions.sql-spec", parser)); tests.addAll(readScriptSpec("/string-functions.sql-spec", parser));
// AwaitsFix: https://github.com/elastic/elasticsearch/issues/32589 tests.addAll(readScriptSpec("/case-functions.sql-spec", parser));
// tests.addAll(readScriptSpec("/case-functions.sql-spec", parser));
return tests; return tests;
} }
@ -60,8 +60,11 @@ public abstract class SqlSpecTestCase extends SpecBaseIntegrationTestCase {
@Override @Override
protected final void doTest() throws Throwable { protected final void doTest() throws Throwable {
boolean goodLocale = !(Locale.getDefault().equals(new Locale.Builder().setLanguageTag("tr").build()) // we skip the tests in case of these locales because ES-SQL is Locale-insensitive for now
|| Locale.getDefault().equals(new Locale.Builder().setLanguageTag("tr-TR").build())); // while H2 does take the Locale into consideration
String[] h2IncompatibleLocales = new String[] {"tr", "az", "tr-TR", "tr-CY", "az-Latn", "az-Cyrl", "az-Latn-AZ", "az-Cyrl-AZ"};
boolean goodLocale = !Arrays.stream(h2IncompatibleLocales)
.anyMatch((l) -> Locale.getDefault().equals(new Locale.Builder().setLanguageTag(l).build()));
if (fileName.startsWith("case-functions")) { if (fileName.startsWith("case-functions")) {
Assume.assumeTrue(goodLocale); Assume.assumeTrue(goodLocale);
} }