Exemplo n.º 1
0
 private void writeXStr(HXStr xstr)
 {
     if (m_iVersion < 3)
     {
         throw new Exception("XStr not supported for version: " + m_iVersion.ToString());
     }
     p(xstr.toZinc());
     flush();
 }
Exemplo n.º 2
0
        private HVal parseXStr(string id)
        {
            if (!char.IsUpper(id[0]))
            {
                err("Invalid XStr type: " + id);
            }
            consume(HaystackToken.lparen);
            if (m_iversion < 3 && ("Bin".CompareTo(id) == 0))
            {
                return(parseBinObsolete());
            }
            string val = consumeStr();

            consume(HaystackToken.rparen);
            return(HXStr.decode(id, val));
        }
 public void testHex()
 {
     // Changed test - unicode code must be valid not random like original test. - this is "NA"
     Assert.IsTrue(read("Type(\"[\\u004e \\u0041]\")").hequals(HXStr.decode("Type", "[\u004e \u0041]")));
     Assert.IsTrue(read("Type(\"[\\u004E \\u0041]\")").hequals(HXStr.decode("Type", "[\u004E \u0041]")));
 }
 public void testZinc()
 {
     verifyZinc(HXStr.decode("Type", "hello"), "Type(\"hello\")");
     verifyZinc(HXStr.decode("Type", "\u0abc"), "Type(\"\u0abc\")");
 }
 public void testCompare()
 {
     Assert.IsTrue(HXStr.decode("Type", "abc").CompareTo(HXStr.decode("Type", "z")) < 0);
     Assert.AreEqual(HXStr.decode("Type", "Foo").CompareTo(HXStr.decode("Type", "Foo")), 0);
 }
 public void testEquality()
 {
     Assert.IsTrue(HXStr.decode("Type", "a").hequals(HXStr.decode("Type", "a")));
     Assert.IsFalse(HXStr.decode("X", "a").hequals(HXStr.decode("X", "b")));
     Assert.IsTrue(HXStr.decode("X", "").hequals(HXStr.decode("X", "")));
 }
 public void testTypeContainsValidCharacters()
 {
     HXStr.decode("TyP0_s", "a");
     Assert.ThrowsException <ArgumentException>(() => HXStr.decode("T.", "a"));
     Assert.ThrowsException <ArgumentException>(() => HXStr.decode("T,", "a"));
 }
 public void testTypeStartsWithUpper()
 {
     HXStr.decode("Type", "a");
     Assert.ThrowsException <ArgumentException>(() => HXStr.decode("type", "a"));
 }