From 1a6d06af7f6112e1fe3bf94e8aaeb0046ba56feb Mon Sep 17 00:00:00 2001 From: finphie <19237170+finphie@users.noreply.github.com> Date: Sat, 24 Jul 2021 16:22:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=82=AF=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Utf8Utility/Utf8String.cs | 23 ------ .../Utf8StringIndexerTest.cs | 77 ------------------- 2 files changed, 100 deletions(-) delete mode 100644 Tests/Utf8Utility.Tests/Utf8StringIndexerTest.cs diff --git a/Source/Utf8Utility/Utf8String.cs b/Source/Utf8Utility/Utf8String.cs index 805cb9d..5286bf9 100644 --- a/Source/Utf8Utility/Utf8String.cs +++ b/Source/Utf8Utility/Utf8String.cs @@ -44,29 +44,6 @@ public readonly struct Utf8String /// public int Length => _value.Length; - /// - /// 指定されたインデックスの値を取得します。 - /// - /// インデックス - /// 指定されたインデックスの値 - public byte this[int index] => _value[index]; - -#if NET5_0_OR_GREATER - /// - /// 指定されたインデックスの値を取得します。 - /// - /// インデックス - /// 指定されたインデックスの値 - public ReadOnlySpan this[Index index] => _value.AsSpan(index); - - /// - /// 指定された範囲の配列を取得します。 - /// - /// 範囲 - /// 指定された範囲の配列 - public ReadOnlySpan this[Range range] => _value.AsSpan(range); -#endif - /// /// 構造体の新しいインスタンスを取得します。 /// diff --git a/Tests/Utf8Utility.Tests/Utf8StringIndexerTest.cs b/Tests/Utf8Utility.Tests/Utf8StringIndexerTest.cs deleted file mode 100644 index 9b52b37..0000000 --- a/Tests/Utf8Utility.Tests/Utf8StringIndexerTest.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace Utf8Utility.Tests -{ - public sealed class Utf8StringIndexerTest - { - [Fact] - public void IntIndex() - { - var x = new Utf8String("abc"); - x[0].Should().Be((byte)'a'); - x[1].Should().Be((byte)'b'); - x[2].Should().Be((byte)'c'); - } - - [Fact] - public void IntIndex_範囲外にアクセス_IndexOutOfRangeExceptionをスローする() - { - FluentActions.Invoking(Execute) - .Should().Throw(); - - static byte Execute() - { - var x = new Utf8String("abc"); - return x[10]; - } - } - -#if NET5_0_OR_GREATER - [Fact] - public void Index() - { - var bytes = System.Text.Encoding.UTF8.GetBytes("abc"); - var x = new Utf8String(bytes); - x[^1].ToArray().Should().BeEquivalentTo(bytes[^1]); - } - - [Fact] - public void Index_範囲外にアクセス_ArgumentOutOfRangeExceptionをスローする() - { - FluentActions.Invoking(Execute) - .Should().Throw(); - - static byte[] Execute() - { - var bytes = System.Text.Encoding.UTF8.GetBytes("abc"); - var x = new Utf8String(bytes); - return x[^10].ToArray(); - } - } - - [Fact] - public void Range() - { - var bytes = System.Text.Encoding.UTF8.GetBytes("abc"); - var x = new Utf8String(bytes); - x[1..].ToArray().Should().BeEquivalentTo(bytes[1..]); - } - - [Fact] - public void Range_範囲外にアクセス_ArgumentOutOfRangeExceptionをスローする() - { - FluentActions.Invoking(Execute) - .Should().Throw(); - - static byte[] Execute() - { - var bytes = System.Text.Encoding.UTF8.GetBytes("abc"); - var x = new Utf8String(bytes); - return x[10..].ToArray(); - } - } -#endif - } -} \ No newline at end of file