Exemple #1
0
    public void ByteDestinationLargerThanSourceDecodeRequestLineReturnsCorrenctLenght()
    {
        var source = Encoding.UTF8.GetBytes("/a%20b".ToCharArray());
        var length = UrlDecoder.DecodeRequestLine(source.AsSpan(), new byte[source.Length + 10], false);

        Assert.Equal(4, length);
    }
Exemple #2
0
    public void StringDestinationLargerThanSourceDecodeRequestLineReturnsCorrenctLenght()
    {
        var source = "/a%20b".ToCharArray();
        var length = UrlDecoder.DecodeRequestLine(source.AsSpan(), new char[source.Length + 10]);

        Assert.Equal(4, length);
    }
Exemple #3
0
    public void ByteDecodeRequestLine(byte[] input, byte[] expected)
    {
        var destination = new byte[input.Length];
        int length      = UrlDecoder.DecodeRequestLine(input.AsSpan(), destination.AsSpan(), false);

        Assert.True(destination.AsSpan(0, length).SequenceEqual(expected.AsSpan()));
    }
Exemple #4
0
    public void StringDecodeRequestLine(string input, string expected)
    {
        var destination = new char[input.Length];
        int length      = UrlDecoder.DecodeRequestLine(input.AsSpan(), destination.AsSpan());

        Assert.True(destination.AsSpan(0, length).SequenceEqual(expected.AsSpan()));
    }
Exemple #5
0
    public void ByteDestinationShorterThanSourceDecodeRequestLineThrows()
    {
        var source = new byte[2];

        Assert.Throws <ArgumentException>(() => UrlDecoder.DecodeRequestLine(source.AsSpan(), source.AsSpan(0, 1), false));
    }
Exemple #6
0
    public void StringDestinationShorterThanSourceDecodeRequestLineThrows()
    {
        var source = new char[2];

        Assert.Throws <ArgumentException>(() => UrlDecoder.DecodeRequestLine(source.AsSpan(), source.AsSpan(0, 1)));
    }