Example #1
0
            protected override void Iterate()
            {
                string id = GetCLV();
                object o  = service.Get(id, out actualID);

                if (o != null)
                {
                    TestFmwk.Logln(" id: " + id + " actual: " + actualID + " result: " + o);
                }
            }
            protected override void Iterate()
            {
                if (--n < 0)
                {
                    n = list.Length - 1;
                }
                string id = list[n];
                object o  = service.Get(id);

                TestFmwk.Logln(" id: " + id + " result: " + o);
            }
Example #3
0
            internal void Test(String s, int start, int count, int index, int offset,
                               int expected, bool flip)
            {
                char[] chars = s.ToCharArray();
                String strng = s.Substring(start, count); // ICU4N: (start + count) - start == count
                int    val1  = UChar.OffsetByCodePoints(chars, start, count,
                                                        index, offset);
                int val2 = UChar.OffsetByCodePoints(strng, index - start,
                                                    offset)
                           + start;

                if (val1 != expected)
                {
                    TestFmwk.Errln("char[] " + Str(s, start, count, index, offset) + "("
                                   + val1 + ") != " + expected);
                }
                else if (val2 != expected)
                {
                    TestFmwk.Errln("String " + Str(s, start, count, index, offset) + "("
                                   + val2 + ") != " + expected);
                }
                else if (TestFmwk.IsVerbose())
                {
                    TestFmwk.Logln(Str(s, start, count, index, offset) + " == "
                                   + expected);
                }

                if (flip)
                {
                    val1 = UChar.OffsetByCodePoints(chars, start, count,
                                                    expected, -offset);
                    val2 = UChar.OffsetByCodePoints(strng, expected
                                                    - start, -offset)
                           + start;
                    if (val1 != index)
                    {
                        TestFmwk.Errln("char[] "
                                       + Str(s, start, count, expected, -offset) + "("
                                       + val1 + ") != " + index);
                    }
                    else if (val2 != index)
                    {
                        TestFmwk.Errln("String "
                                       + Str(s, start, count, expected, -offset) + "("
                                       + val2 + ") != " + index);
                    }
                    else if (TestFmwk.IsVerbose())
                    {
                        TestFmwk.Logln(Str(s, start, count, expected, -offset) + " == "
                                       + index);
                    }
                }
            }
            protected override void Iterate()
            {
                var ids  = service.GetVisibleIDs();
                var iter = ids.GetEnumerator();
                int n    = 10;

                while (--n >= 0 && iter.MoveNext())
                {
                    string id     = (string)iter.Current;
                    object result = service.Get(id);
                    TestFmwk.Logln("iter: " + n + " id: " + id + " result: " + result);
                }
            }
            protected override void Iterate()
            {
                int s = factories.Count;

                if (s == 0)
                {
                    factories = service.Factories();
                }
                else
                {
                    int n = r.Next(s);
                    //IFactory f = (IFactory)factories.RemoveAt(n);
                    IServiceFactory f = factories[n];
                    factories.Remove(f);
                    bool success = service.UnregisterFactory(f);
                    TestFmwk.Logln("factory: " + f + (success ? " succeeded." : " *** failed."));
                }
            }
Example #6
0
        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
            }
        }
            protected override void Iterate()
            {
                var names = GetDisplayNames(service, locale);
                var iter  = names.GetEnumerator();
                int n     = 10;

                while (--n >= 0 && iter.MoveNext())
                {
                    var    e      = iter.Current;
                    string dname  = (string)e.Key;
                    string id     = (string)e.Value;
                    object result = service.Get(id);

                    // Note: IllegalMonitorStateException is thrown by the code
                    // below on IBM JRE5 for AIX 64bit.  For some reason, converting
                    // int to string out of this statement resolves the issue.

                    string num = (n).ToString(CultureInfo.InvariantCulture);
                    TestFmwk.Logln(" iter: " + num +
                                   " dname: " + dname +
                                   " id: " + id +
                                   " result: " + result);
                }
            }
Example #8
0
 public string CheckSourceLocale()
 {
     return(TestFmwk.SourceLocation());
 }
Example #9
0
        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
                }
            }
        }