Beispiel #1
0
        public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
        {
            var cultureNames = Helpers.TestCultureNames;

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var provider = new CaseInsensitiveHashCodeProvider(culture);

                // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
                // but rather U+0130.
                Assert.Equal(
                    culture.Name != "tr-TR",
                    provider.GetHashCode("file") == provider.GetHashCode("FILE"));
            }
        }
Beispiel #2
0
        public void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
        {
            var cultureNames = Helpers.TestCultureNames;

            foreach (string cultureName in cultureNames)
            {
                CultureInfo newCulture;
                try
                {
                    newCulture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                using (new ThreadCultureChange(newCulture))
                {
                    var provider = new CaseInsensitiveHashCodeProvider();
                    Assert.Equal(provider.GetHashCode(a), provider.GetHashCode(a));
                    Assert.Equal(provider.GetHashCode(b), provider.GetHashCode(b));
                    Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b));
                }
            }
        }
Beispiel #3
0
        public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
        {
            var cultureNames = new string[]
            {
                "cs-CZ", "da-DK", "de-DE", "el-GR", "en-US",
                "es-ES", "fi-FI", "fr-FR", "hu-HU", "it-IT",
                "ja-JP", "ko-KR", "nb-NO", "nl-NL", "pl-PL",
                "pt-BR", "pt-PT", "ru-RU", "sv-SE", "tr-TR",
                "zh-CN", "zh-HK", "zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var provider = new CaseInsensitiveHashCodeProvider(culture);

                // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
                // but rather U+0130.
                Assert.Equal(
                    culture.Name != "tr-TR",
                    provider.GetHashCode("file") == provider.GetHashCode("FILE"));
            }
        }
Beispiel #4
0
        public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
        {
            var cultureNames = new string[]
            {
                "cs-CZ", "da-DK", "de-DE", "el-GR", "en-US",
                "es-ES", "fi-FI", "fr-FR", "hu-HU", "it-IT",
                "ja-JP", "ko-KR", "nb-NO", "nl-NL", "pl-PL",
                "pt-BR", "pt-PT", "ru-RU", "sv-SE", "tr-TR",
                "zh-CN", "zh-HK", "zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var provider = new CaseInsensitiveHashCodeProvider(culture);
                Assert.Equal(provider.GetHashCode(a), provider.GetHashCode(a));
                Assert.Equal(provider.GetHashCode(b), provider.GetHashCode(b));
                Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b));
            }
        }
 public static void Ctor_Empty_GetHashCodeCompare(object a, object b, bool expected)
 {
     var provider = new CaseInsensitiveHashCodeProvider();
     Assert.Equal(provider.GetHashCode(a), provider.GetHashCode(a));
     Assert.Equal(provider.GetHashCode(b), provider.GetHashCode(b));
     Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b));
 }
Beispiel #6
0
        public void Default_MS()
        {
            // MS always returns new instance
            CaseInsensitiveHashCodeProvider cih1 = CaseInsensitiveHashCodeProvider.Default;
            CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.Default;

            Assert.IsFalse(object.ReferenceEquals(cih1, cih2));
        }
Beispiel #7
0
        public void Ctor_Empty_GetHashCodeCompare(object a, object b, bool expected)
        {
            var provider = new CaseInsensitiveHashCodeProvider();

            Assert.Equal(provider.GetHashCode(a), provider.GetHashCode(a));
            Assert.Equal(provider.GetHashCode(b), provider.GetHashCode(b));
            Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b));
        }
Beispiel #8
0
        public void Default_Mono()
        {
            // we return same instance if current culture did not change
            CaseInsensitiveHashCodeProvider cih1 = CaseInsensitiveHashCodeProvider.Default;
            CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.Default;

            Assert.IsTrue(object.ReferenceEquals(cih1, cih2));
        }
Beispiel #9
0
        private static void InitHash()
        {
#if (NET_1_1)
            CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);
            _directivesHash = new Hashtable(provider, comparer);

            // Use Hashtable 'cause is O(1) in Contains (ArrayList is O(n))
            Hashtable valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in _tempateAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("CodeTemplate", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in _importAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("Import", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in _assemblyAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("Assembly", valid_attributes);
#else
            _directivesHash = new Hashtable(StringComparer.OrdinalIgnoreCase);

            // Use Hashtable 'cause is O(1) in Contains (ArrayList is O(n))
            Hashtable valid_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (string att in _tempateAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("CodeTemplate", valid_attributes);

            valid_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (string att in _importAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("Import", valid_attributes);

            valid_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
            foreach (string att in _assemblyAttributes)
            {
                valid_attributes.Add(att, null);
            }
            _directivesHash.Add("Assembly", valid_attributes);
#endif
        }
Beispiel #10
0
        public void Clear()
        {
            if (m_InternalHashTable != null)
            {
                m_InternalHashTable.Clear();
            }

            CaseInsensitiveHashCodeProvider HashCodeProvider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         Comparer         = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);

            m_InternalHashTable = new Hashtable(HashCodeProvider, Comparer);
        }
        protected virtual IDictionary CreateDictionary(object parent)
        {
#if NET_1_0
            CaseInsensitiveHashCodeProvider hcp      = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);
#else
            CaseInsensitiveHashCodeProvider hcp      = CaseInsensitiveHashCodeProvider.DefaultInvariant;
            CaseInsensitiveComparer         comparer = CaseInsensitiveComparer.DefaultInvariant;
#endif

            return(parent != null ?
                   new Hashtable((IDictionary)parent, hcp, comparer) :
                   new Hashtable(hcp, comparer));
        }
Beispiel #12
0
        public void Deserialize()
        {
            BinaryFormatter bf = new BinaryFormatter();

            MemoryStream ms = new MemoryStream(serialized_en_us);
            CaseInsensitiveHashCodeProvider enus = (CaseInsensitiveHashCodeProvider)bf.Deserialize(ms);

            Assert.IsNotNull(enus, "en-US");

            ms = new MemoryStream(serialized_fr_ca);
            CaseInsensitiveHashCodeProvider frca = (CaseInsensitiveHashCodeProvider)bf.Deserialize(ms);

            Assert.IsNotNull(frca, "fr-CA");
        }
Beispiel #13
0
        public void SerializationRoundtrip()
        {
            CaseInsensitiveHashCodeProvider enus = new CaseInsensitiveHashCodeProvider(new CultureInfo("en-US"));
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream    ms = new MemoryStream();

            bf.Serialize(ms, enus);

            ms.Position = 0;
            CaseInsensitiveHashCodeProvider clone = (CaseInsensitiveHashCodeProvider)bf.Deserialize(ms);

            Assert.AreEqual(enus.GetHashCode(String.Empty), clone.GetHashCode(String.Empty), "GetHashCode(string)");
            Assert.AreEqual(enus.GetHashCode(Int32.MinValue), clone.GetHashCode(Int32.MinValue), "GetHashCode(int)");
        }
Beispiel #14
0
        public void HashCode()
        {
            CaseInsensitiveHashCodeProvider cih = new CaseInsensitiveHashCodeProvider();
            int h1 = cih.GetHashCode("Test String");
            int h2 = cih.GetHashCode("test string");
            int h3 = cih.GetHashCode("TEST STRING");

            Assert.IsTrue(h1 == h2, "Mixed Case != lower case");
            Assert.IsTrue(h1 == h3, "Mixed Case != UPPER CASE");

            h1 = cih.GetHashCode("one");
            h2 = cih.GetHashCode("another");
            // Actually this is quite possible.
            Assert.IsFalse(h1 == h2);
        }
Beispiel #15
0
        public void DefaultInvariant()
        {
            CaseInsensitiveHashCodeProvider cih = new CaseInsensitiveHashCodeProvider(
                CultureInfo.InvariantCulture);
            int h1 = cih.GetHashCode("Test String");

            cih = CaseInsensitiveHashCodeProvider.DefaultInvariant;
            int h2 = cih.GetHashCode("Test String");

            Assert.AreEqual(h1, h2, "#1");

            CaseInsensitiveHashCodeProvider cih1 = CaseInsensitiveHashCodeProvider.DefaultInvariant;
            CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.DefaultInvariant;

            Assert.IsTrue(object.ReferenceEquals(cih1, cih2));
        }
Beispiel #16
0
        public void Constructor1_Serialization()
        {
            CaseInsensitiveHashCodeProvider cihcp = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream    ms = new MemoryStream();

            bf.Serialize(ms, cihcp);
            byte[] ser1 = ms.ToArray();

            cihcp = CaseInsensitiveHashCodeProvider.DefaultInvariant;
            ms    = new MemoryStream();
            bf.Serialize(ms, cihcp);
            byte[] ser2 = ms.ToArray();

            Assert.AreEqual(ser1, ser2, "#1");
        }
Beispiel #17
0
        public void Clear()
        {
            m_DefaultLanguage = Language.English;
            m_CurrentLanguage = Language.English;
            m_InstanceCounter = 0;

            if (m_InternalLanguageHashTable != null)
            {
                m_InternalLanguageHashTable.Clear();
            }

            CaseInsensitiveHashCodeProvider HashCodeProvider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         Comparer         = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);

            m_InternalLanguageHashTable = new Hashtable(HashCodeProvider, Comparer);
        }
Beispiel #18
0
        public void Deserialize()
        {
#if TARGET_JVM
            BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter(false);
#else
            BinaryFormatter bf = new BinaryFormatter();
#endif // TARGET_JVM

            MemoryStream ms = new MemoryStream(serialized_en_us);
            CaseInsensitiveHashCodeProvider enus = (CaseInsensitiveHashCodeProvider)bf.Deserialize(ms);
            Assert.IsNotNull(enus, "en-US");

            ms = new MemoryStream(serialized_fr_ca);
            CaseInsensitiveHashCodeProvider frca = (CaseInsensitiveHashCodeProvider)bf.Deserialize(ms);
            Assert.IsNotNull(frca, "fr-CA");
        }
Beispiel #19
0
        static QueryTokenizer()
        {
            CultureInfo usCulture = new CultureInfo("en-US");

            theComparer = new CaseInsensitiveComparer(usCulture);

            CaseInsensitiveHashCodeProvider hashCodeProvider = new CaseInsensitiveHashCodeProvider(usCulture);

            theKeywords = new Hashtable(hashCodeProvider, theComparer);

            theKeywords["SELECT"]      = TokenType.KeywordSelect;
            theKeywords["TRUE"]        = TokenType.Boolean;
            theKeywords["FALSE"]       = TokenType.Boolean;
            theKeywords["PREFIX"]      = TokenType.KeywordPrefix;
            theKeywords["WHERE"]       = TokenType.KeywordWhere;
            theKeywords["FILTER"]      = TokenType.KeywordFilter;
            theKeywords["STR"]         = TokenType.KeywordStr;
            theKeywords["LANG"]        = TokenType.KeywordLang;
            theKeywords["DATATYPE"]    = TokenType.KeywordDataType;
            theKeywords["LANGMATCHES"] = TokenType.KeywordLangMatches;
            theKeywords["BOUND"]       = TokenType.KeywordBound;
            theKeywords["ISIRI"]       = TokenType.KeywordIsIri;
            theKeywords["ISURI"]       = TokenType.KeywordIsUri;
            theKeywords["ISBLANK"]     = TokenType.KeywordIsBlank;
            theKeywords["ISLITERAL"]   = TokenType.KeywordIsLiteral;
            theKeywords["REGEX"]       = TokenType.KeywordRegex;
            theKeywords["UNION"]       = TokenType.KeywordUnion;
            theKeywords["LIMIT"]       = TokenType.KeywordLimit;
            theKeywords["OFFSET"]      = TokenType.KeywordOffset;
            theKeywords["ORDER"]       = TokenType.KeywordOrder;
            theKeywords["BY"]          = TokenType.KeywordBy;
            theKeywords["ASC"]         = TokenType.KeywordAsc;
            theKeywords["DESC"]        = TokenType.KeywordDesc;
            theKeywords["FROM"]        = TokenType.KeywordFrom;
            theKeywords["NAMED"]       = TokenType.KeywordNamed;
            theKeywords["BASE"]        = TokenType.KeywordBase;
            theKeywords["DISTINCT"]    = TokenType.KeywordDistinct;
            theKeywords["CONSTRUCT"]   = TokenType.KeywordConstruct;
            theKeywords["DESCRIBE"]    = TokenType.KeywordDescribe;
            theKeywords["ASK"]         = TokenType.KeywordAsk;
            theKeywords["OPTIONAL"]    = TokenType.KeywordOptional;
            theKeywords["GRAPH"]       = TokenType.KeywordGraph;
            theKeywords["A"]           = TokenType.KeywordA;
        }
Beispiel #20
0
        public void Default()
        {
            CaseInsensitiveHashCodeProvider cih = new CaseInsensitiveHashCodeProvider(
                CultureInfo.CurrentCulture);
            int h1 = cih.GetHashCode("Test String");

            cih = CaseInsensitiveHashCodeProvider.Default;
            int h2 = cih.GetHashCode("Test String");

            Assert.AreEqual(h1, h2, "#1");

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            CaseInsensitiveHashCodeProvider cih1 = CaseInsensitiveHashCodeProvider.Default;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-BE");
            CaseInsensitiveHashCodeProvider cih2 = CaseInsensitiveHashCodeProvider.Default;

            Assert.IsFalse(object.ReferenceEquals(cih1, cih2), "#2");
        }
Beispiel #21
0
        public DocumentDirective(string name, IDictionary properties, int key)
        {
            this.name = name;
            this.key  = key;

            CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);

            this.properties = new Hashtable(provider, comparer);

            if (properties != null)
            {
                foreach (DictionaryEntry de in properties)
                {
                    CheckValidPropertyName(name, (string)de.Key);
                    CheckValidPropertyValue(name, (string)de.Key, (string)de.Value);
                    this.properties.Add(de.Key, de.Value);
                }
            }
        }
Beispiel #22
0
        private void initDocument(Control parent, DesignerHost host)
        {
            System.Diagnostics.Trace.WriteLine("Creating document...");
            if (!(parent is WebFormPage))
            {
                throw new NotImplementedException("Only WebFormsPages can have a document for now");
            }
            this.parent = parent;
            this.host   = host;

            if (!host.Loading)
            {
                throw new InvalidOperationException("The document cannot be initialised or loaded unless the host is loading");
            }

            CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);

            directives = new Hashtable(provider, comparer);

            this.aspParser = new DesignTimeParser(host, this);
        }
        public static void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
        {
            var cultureNames = new string[]
            {
                "cs-CZ","da-DK","de-DE","el-GR","en-US",
                "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
                "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
                "pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
                "zh-CN","zh-HK","zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo newCulture;
                try
                {
                    newCulture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                CultureInfo origCulture = CultureInfo.CurrentCulture;
                try
                {
                    CultureInfo.CurrentCulture = newCulture;
                    var provider = new CaseInsensitiveHashCodeProvider();
                    Assert.Equal(provider.GetHashCode(a), provider.GetHashCode(a));
                    Assert.Equal(provider.GetHashCode(b), provider.GetHashCode(b));
                    Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b));
                }
                finally
                {
                    CultureInfo.CurrentCulture = origCulture;
                }
            }
        }
Beispiel #24
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        CaseInsensitiveHashCodeProvider cis;

        try
        {
            do
            {
                cis = new CaseInsensitiveHashCodeProvider();
                iCountTestcases++;
                if (cis == null)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_8753bdd! Expected value not returned, ");
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
        public void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
        {
            RemoteExecutorForUap.Invoke((ra, rb, rexpected) =>
            {
                var cultureNames = new string[]
                {
                    "cs-CZ", "da-DK", "de-DE", "el-GR", "en-US",
                    "es-ES", "fi-FI", "fr-FR", "hu-HU", "it-IT",
                    "ja-JP", "ko-KR", "nb-NO", "nl-NL", "pl-PL",
                    "pt-BR", "pt-PT", "ru-RU", "sv-SE", "tr-TR",
                    "zh-CN", "zh-HK", "zh-TW"
                };

                bool.TryParse(rexpected, out bool expectedResult);

                foreach (string cultureName in cultureNames)
                {
                    CultureInfo newCulture;
                    try
                    {
                        newCulture = new CultureInfo(cultureName);
                    }
                    catch (CultureNotFoundException)
                    {
                        continue;
                    }

                    using (new ThreadCultureChange(newCulture))
                    {
                        var provider = new CaseInsensitiveHashCodeProvider();
                        Assert.Equal(provider.GetHashCode(ra), provider.GetHashCode(ra));
                        Assert.Equal(provider.GetHashCode(rb), provider.GetHashCode(rb));
                        Assert.Equal(expectedResult, provider.GetHashCode(ra) == provider.GetHashCode(rb));
                    }
                }
            }, a.ToString(), b.ToString(), expected.ToString()).Dispose();
        }
 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     CaseInsensitiveHashCodeProvider cis;
     try 
     {
         do
         {
             cis = new CaseInsensitiveHashCodeProvider();
             iCountTestcases++;
             if(cis==null) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_8753bdd! Expected value not returned, ");
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     CaseInsensitiveHashCodeProvider cis;            
     String strValue1;
     String strValue2;
     Int32 iValue;
     try 
     {
         do
         {
             cis = new CaseInsensitiveHashCodeProvider();
             iCountTestcases++;
             if(cis==null) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_8753bdd! Expected value not returned, ");
             }
             strValue1 = "hello world";
             strValue2 = strValue1.ToUpper();
             iCountTestcases++;
             if(cis.GetHashCode(strValue1)!=cis.GetHashCode(strValue2)) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_8753bdd! Expected value not returned, " + cis.GetHashCode(strValue1) + " " + cis.GetHashCode(strValue2));
             }
             strValue2 = "Completely different";
             iCountTestcases++;
             if(cis.GetHashCode(strValue1)==cis.GetHashCode(strValue2)) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_87453gdg! Expected value not returned, " + cis.GetHashCode(strValue1) + " " + cis.GetHashCode(strValue2));
             }
             iValue = 5;
             iCountTestcases++;
             if(cis.GetHashCode(iValue)!=iValue.GetHashCode()) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_752dsg! Expected value not returned, " + cis.GetHashCode(iValue) + " " + iValue.GetHashCode());
             }
             try
             {
                 iCountTestcases++;
                 cis.GetHashCode(null);
                 iCountErrors++;
                 Console.WriteLine("Err_7439dg! Exception not thrown");
             }
             catch(ArgumentNullException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_6572fdg! Unexpected exception thrown, " + ex);
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Beispiel #28
0
        private static void InitHash()
        {
            CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
            CaseInsensitiveComparer         comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture);

            directivesHash = new Hashtable(provider, comparer);

            // Use Hashtable 'cause is O(1) in Contains (ArrayList is O(n))
            Hashtable valid_attributes = new Hashtable(provider, comparer);

            foreach (string att in page_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("PAGE", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in control_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("CONTROL", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in import_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("IMPORT", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in implements_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("IMPLEMENTS", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in register_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("REGISTER", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in assembly_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("ASSEMBLY", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in outputcache_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("OUTPUTCACHE", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in reference_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("REFERENCE", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in webservice_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("WEBSERVICE", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            // same attributes as webservice
            foreach (string att in webservice_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("WEBHANDLER", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in application_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("APPLICATION", valid_attributes);

#if NET_2_0
            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in mastertype_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("MASTERTYPE", valid_attributes);

            valid_attributes = new Hashtable(provider, comparer);
            foreach (string att in control_atts)
            {
                valid_attributes.Add(att, null);
            }
            directivesHash.Add("MASTER", valid_attributes);
#endif
        }
Beispiel #29
0
 /// <include file='doc\DataColumnCollection.uex' path='docs/doc[@for="DataColumnCollection.DataColumnCollection"]/*' />
 /// <devdoc>
 /// DataColumnCollection constructor.  Used only by DataTable.
 /// </devdoc>
 internal DataColumnCollection(DataTable table)
 {
     this.table       = table;
     columnFromName   = new Hashtable();
     hashCodeProvider = new CaseInsensitiveHashCodeProvider(table.Locale);
 }
Beispiel #30
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        CaseInsensitiveHashCodeProvider cis;
        CaseInsensitiveHashCodeProvider cisDefault;

        CultureInfo[] cultures;
        try
        {
            do
            {
                strLoc   = "Loc_384sdg";
                cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
                for (int i = 0; i < cultures.Length; i++)
                {
                    iCountTestcases++;
                    cis        = new CaseInsensitiveHashCodeProvider(cultures[i]);
                    cisDefault = CaseInsensitiveHashCodeProvider.Default;
                    if (cisDefault.GetHashCode("hello") != cisDefault.GetHashCode("HELLO"))
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                    }
                    if (cisDefault.GetHashCode("hello") != cisDefault.GetHashCode("hello"))
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_4953rewg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                    }
                    if (cisDefault.GetHashCode("hello") == cisDefault.GetHashCode("mello"))
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_94375sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                    }
                    if (cisDefault.GetHashCode(5) != cisDefault.GetHashCode(5))
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_9745sdg! wrong value returned");
                    }
                    if (cisDefault.GetHashCode(5) == cisDefault.GetHashCode(10))
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_9745sdg! wrong value returned");
                    }
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     CaseInsensitiveHashCodeProvider cis;
     CaseInsensitiveHashCodeProvider cisDefault;
     CultureInfo[] cultures;
     try 
     {
         do
         {
             strLoc = "Loc_384sdg";
             cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
             for(int i=0; i<cultures.Length; i++)
             {
                 iCountTestcases++;
                 cis = new CaseInsensitiveHashCodeProvider(cultures[i]);
                 cisDefault = CaseInsensitiveHashCodeProvider.Default;
                 if(cisDefault.GetHashCode("hello") != cisDefault.GetHashCode("HELLO"))
                 {
                     iCountErrors++;
                     Console.WriteLine( "Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                 }
                 if(cisDefault.GetHashCode("hello") != cisDefault.GetHashCode("hello"))
                 {
                     iCountErrors++;
                     Console.WriteLine( "Err_4953rewg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                 }
                 if(cisDefault.GetHashCode("hello") == cisDefault.GetHashCode("mello"))
                 {
                     iCountErrors++;
                     Console.WriteLine( "Err_94375sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", cisDefault.GetHashCode("hello"), cisDefault.GetHashCode("HELLO"));
                 }
                 if(cisDefault.GetHashCode(5) != cisDefault.GetHashCode(5))
                 {
                     iCountErrors++;
                     Console.WriteLine( "Err_9745sdg! wrong value returned");
                 }
                 if(cisDefault.GetHashCode(5) == cisDefault.GetHashCode(10))
                 {
                     iCountErrors++;
                     Console.WriteLine( "Err_9745sdg! wrong value returned");
                 }    		
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
        public static void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
        {
            var cultureNames = new string[]
            {
                "cs-CZ","da-DK","de-DE","el-GR","en-US",
                "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
                "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
                "pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
                "zh-CN","zh-HK","zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var provider = new CaseInsensitiveHashCodeProvider(culture);

                // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
                // but rather "İ" (U+0130)
                Assert.Equal(
                    culture.Name != "tr-TR",
                    provider.GetHashCode("file") == provider.GetHashCode("FILE"));
            }
        }
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        CaseInsensitiveHashCodeProvider cis;
        String strValue1;
        String strValue2;
        Int32  iValue;

        try
        {
            do
            {
                cis = new CaseInsensitiveHashCodeProvider();
                iCountTestcases++;
                if (cis == null)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_8753bdd! Expected value not returned, ");
                }
                strValue1 = "hello world";
                strValue2 = strValue1.ToUpper();
                iCountTestcases++;
                if (cis.GetHashCode(strValue1) != cis.GetHashCode(strValue2))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_8753bdd! Expected value not returned, " + cis.GetHashCode(strValue1) + " " + cis.GetHashCode(strValue2));
                }
                strValue2 = "Completely different";
                iCountTestcases++;
                if (cis.GetHashCode(strValue1) == cis.GetHashCode(strValue2))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_87453gdg! Expected value not returned, " + cis.GetHashCode(strValue1) + " " + cis.GetHashCode(strValue2));
                }
                iValue = 5;
                iCountTestcases++;
                if (cis.GetHashCode(iValue) != iValue.GetHashCode())
                {
                    iCountErrors++;
                    Console.WriteLine("Err_752dsg! Expected value not returned, " + cis.GetHashCode(iValue) + " " + iValue.GetHashCode());
                }
                try
                {
                    iCountTestcases++;
                    cis.GetHashCode(null);
                    iCountErrors++;
                    Console.WriteLine("Err_7439dg! Exception not thrown");
                }
                catch (ArgumentNullException)
                {
                }
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_6572fdg! Unexpected exception thrown, " + ex);
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }