Files
dotnet-runtime/src/libraries/System.Text.Encoding/tests/UTF32Encoding/UTF32EncodingGetMaxByteCount.cs
T
Hugh Bellamy d0130418af Remove duplicate tests from System.Text.Encoding.Extensions
- Only added tests for GetMaxByteCount/GetMaxByteCount and
encoding/decoding nothing


Commit migrated from https://github.com/dotnet/corefx/commit/99eb9ce017c08d7182ee95f9e5d63fcb82d6d5b6
2016-04-27 18:42:29 +01:00

33 lines
1.4 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;
namespace System.Text.Tests
{
public class UTF32EncodingGetMaxByteCount
{
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
[InlineData(4)]
[InlineData(10)]
[InlineData(268435455)]
[InlineData(int.MaxValue / 4 - 1)]
public void GetMaxByteCount(int charCount)
{
int expected = (charCount + 1) * 4;
Assert.Equal(expected, new UTF32Encoding(true, false, false).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(true, true, false).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(true, false, true).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(true, true, true).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(false, true, true).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(false, true, false).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(false, false, true).GetMaxByteCount(charCount));
Assert.Equal(expected, new UTF32Encoding(false, false, false).GetMaxByteCount(charCount));
}
}
}