public void TestThreads() { if (TestFmwk.GetExhaustiveness() >= 9) { // Exhaustive test. Run longer. iterationCount = 1000000; } for (int i = 0; i < 8; i++) { Worker thread = new Worker(this); threads.Add(thread); thread.Start(); } long expectedCount = 0; foreach (Worker thread in threads) { #if !NETCOREAPP1_0 try { #endif thread.Join(); if (expectedCount == 0) { expectedCount = thread.count; } else { if (expectedCount != thread.count) { Errln("Threads gave differing results."); } } #if !NETCOREAPP1_0 } catch (ThreadInterruptedException e) { Errln(e.ToString()); } #endif } }
public void TestScripts() { // get a couple of characters of each script for testing StringBuffer testBuffer = new StringBuffer(); for (int script = 0; script < UScript.CodeLimit; ++script) { UnicodeSet test = new UnicodeSet().ApplyPropertyAlias("script", UScript.GetName(script)); int count = Math.Min(20, test.Count); for (int i = 0; i < count; ++i) { testBuffer.Append(UTF16.ValueOf(test[i])); } } { String test = testBuffer.ToString(); Logln("Test line: " + test); int inclusion = TestFmwk.GetExhaustiveness(); bool testedUnavailableScript = false; for (int script = 0; script < UScript.CodeLimit; ++script) { if (script == UScript.Common || script == UScript.Inherited) { continue; } // if the inclusion rate is not 10, skip all but a small number of items. // Make sure, however, that we test at least one unavailable script if (inclusion < 10 && script != UScript.Latin && script != UScript.Han && script != UScript.Hiragana && testedUnavailableScript ) { continue; } String scriptName = UScript.GetName(script); // long name UCultureInfo locale = new UCultureInfo(scriptName); if (locale.Language.Equals("new") || locale.Language.Equals("pau")) { if (logKnownIssue("11171", "long script name loosely looks like a locale ID with a known likely script")) { continue; } } Transliterator t; try { t = Transliterator.GetInstance("any-" + scriptName); } catch (Exception e) { testedUnavailableScript = true; Logln("Skipping unavailable: " + scriptName); continue; // we don't handle all scripts } Logln("Checking: " + scriptName); if (t != null) { t.Transform(test); // just verify we don't crash } String shortScriptName = UScript.GetShortName(script); // 4-letter script code try { t = Transliterator.GetInstance("any-" + shortScriptName); } catch (Exception e) { Errln("Transliterator.GetInstance() worked for \"any-" + scriptName + "\" but not for \"any-" + shortScriptName + '\"'); } t.Transform(test); // just verify we don't crash } } }