コード例 #1
0
        public void IndexOf()
        {
            AsciiString foo = AsciiString.Of("This is a test");
            int         i1  = foo.IndexOf(' ', 0);

            Assert.Equal(4, i1);
            int i2 = foo.IndexOf(' ', i1 + 1);

            Assert.Equal(7, i2);
            int i3 = foo.IndexOf(' ', i2 + 1);

            Assert.Equal(9, i3);
            Assert.True(i3 + 1 < foo.Count);
            int i4 = foo.IndexOf(' ', i3 + 1);

            Assert.Equal(-1, i4);
        }
コード例 #2
0
 public void StaticIndexOfChar()
 {
     Assert.Equal(-1, AsciiString.IndexOf(null, 'a', 0));
     Assert.Equal(-1, AsciiString.IndexOf((AsciiString)"", 'a', 0));
     Assert.Equal(-1, AsciiString.IndexOf((AsciiString)"abc", 'd', 0));
     Assert.Equal(-1, AsciiString.IndexOf((AsciiString)"aabaabaa", 'A', 0));
     Assert.Equal(0, AsciiString.IndexOf((AsciiString)"aabaabaa", 'a', 0));
     Assert.Equal(1, AsciiString.IndexOf((AsciiString)"aabaabaa", 'a', 1));
     Assert.Equal(3, AsciiString.IndexOf((AsciiString)"aabaabaa", 'a', 2));
     Assert.Equal(3, AsciiString.IndexOf((AsciiString)"aabdabaa", 'd', 1));
 }
コード例 #3
0
ファイル: HttpConversionUtil.cs プロジェクト: wxlonstar/Fenix
 /// <summary>
 /// Filter the <see cref="HttpHeaderNames.Te"/> header according to the
 /// <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>.
 /// </summary>
 /// <param name="entry">An entry whose name is <see cref="HttpHeaderNames.Te"/>.</param>
 /// <param name="output">the resulting HTTP/2 headers.</param>
 private static void ToHttp2HeadersFilterTE(HeaderEntry <AsciiString, ICharSequence> entry, IHttp2Headers output)
 {
     if (AsciiString.IndexOf(entry.Value, ',', 0) == -1)
     {
         if (AsciiString.ContentEqualsIgnoreCase(AsciiString.Trim(entry.Value), HttpHeaderValues.Trailers))
         {
             _ = output.Add(HttpHeaderNames.Te, HttpHeaderValues.Trailers);
         }
     }
     else
     {
         var teValues = StringUtil.UnescapeCsvFields(entry.Value);
         foreach (var teValue in teValues)
         {
             if (AsciiString.ContentEqualsIgnoreCase(AsciiString.Trim(teValue), HttpHeaderValues.Trailers))
             {
                 _ = output.Add(HttpHeaderNames.Te, HttpHeaderValues.Trailers);
                 break;
             }
         }
     }
 }