Skip to content

Commit

Permalink
Update .NET versions, improve implementation performance
Browse files Browse the repository at this point in the history
  • Loading branch information
bijij committed Jan 6, 2024
1 parent 700f82a commit 47b89ef
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 225 deletions.
4 changes: 2 additions & 2 deletions Bottom.NET.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bottom", "src\Bottom\Bottom.csproj", "{9B492510-BB86-4A94-B3E1-8E3FFCFAE282}"
EndProject
Expand Down
6 changes: 3 additions & 3 deletions src/Bottom.Bench/Bottom.Bench.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/Bottom.CLI/Bottom.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Bottom.CLI</RootNamespace>
<StartupObject>Bottom.CLI.Program</StartupObject>
<Version>3.0.0.0</Version>
<AssemblyName>Bottom.CLI</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Bottom.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ο»Ώusing System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.NamingConventionBinder;
using System.IO;
using System.Text;

Expand Down
13 changes: 8 additions & 5 deletions src/Bottom.UnitTest/Bottom.UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
178 changes: 72 additions & 106 deletions src/Bottom.UnitTest/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,125 +6,91 @@ namespace Bottom.UnitTest
public class UnitTests
{
[TestMethod]
public void TestIsCharacterValueGroup()
{
Assert.AreEqual(
true,
Bottomify.IsCharacterValueGroup("πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ")
);
Assert.AreEqual(
false,
Bottomify.IsCharacterValueGroup("πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")
);
Assert.AreEqual(
true,
Bottomify.IsCharacterValueGroup("hello")
);
}
[DataRow(true, "πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ")]
[DataRow(true, "β€οΈπŸ‘‰πŸ‘ˆ")]
[DataRow(false, "πŸ’–βœ¨βœ¨βœ¨,,,,")]
[DataRow(false, "πŸ’–β€οΈπŸ‘‰πŸ‘ˆ")]
[DataRow(true, "πŸ’–βœ¨βœ¨βœ¨,,,,\u200B")]
[DataRow(false, "πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")]
[DataRow(false, "πŸ‘‰πŸ‘ˆ")]
[DataRow(false, "hello")]
public void TestIsCharacterValueGroup(bool expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.IsCharacterValueGroup(input)
);


[TestMethod]
public void TestIsEncoded()
{
Assert.AreEqual(
true,
Bottomify.IsEncoded("πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")
);
Assert.AreEqual(
false,
Bottomify.IsEncoded("Hello")
);
}
[DataRow(true, "πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")]
[DataRow(false, "πŸ’–βœ¨βœ¨βœ¨,,,,")]
[DataRow(false, "Hello")]
[DataRow(true, "")]
public void TestIsEncoded(bool expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.IsEncoded(input)
);


[TestMethod]
public void TestStringEncode()
{
Assert.AreEqual(
"πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ",
Bottomify.EncodeString("Test")
);
Assert.AreEqual(
"πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆβ€οΈπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ",
Bottomify.EncodeString("Te\0st")
);
}
[DataRow("πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ", "Test")]
[DataRow("πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆβ€οΈπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ", "Te\0st")]
public void TestStringEncode(string expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.EncodeString(input)
);


[TestMethod]
public void TestByteEncode()
{
Assert.AreEqual(
"πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ",
Bottomify.EncodeByte((byte)'h')
);
Assert.AreEqual(
"β€οΈπŸ‘‰πŸ‘ˆ",
Bottomify.EncodeByte((byte)'\0')
);
}
[DataRow("πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ", (byte)'h')]
[DataRow("πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ", (byte)'a')]
[DataRow("β€οΈπŸ‘‰πŸ‘ˆ", (byte)'\0')]
public void TestByteEncode(string expectedResult, byte input) => Assert.AreEqual(
expectedResult,
Bottomify.EncodeByte(input)
);


[TestMethod]
public void TestCharacterValueGroupDecode()
{
Assert.AreEqual(
(byte)'h',
Bottomify.DecodeCharacterValueGroup("πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ")
);
Assert.AreEqual(
(byte)'a',
Bottomify.DecodeCharacterValueGroup("πŸ’–βœ¨βœ¨βœ¨βœ¨,,,,,,,πŸ‘‰πŸ‘ˆ")
);
Assert.AreEqual(
(byte)'\0',
Bottomify.DecodeCharacterValueGroup("β€οΈπŸ‘‰πŸ‘ˆ")
);
}
[DataRow((byte)'h', "πŸ’–πŸ’–,,,,πŸ‘‰πŸ‘ˆ")]
[DataRow((byte)'a', "πŸ’–βœ¨βœ¨βœ¨βœ¨,,,,,,,πŸ‘‰πŸ‘ˆ")]
[DataRow((byte)'a', "πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ")]
[DataRow((byte)'\0', "β€οΈπŸ‘‰πŸ‘ˆ")]
public void TestCharacterValueGroupDecode(byte expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.DecodeCharacterValueGroup(input)
);


[TestMethod]
public void TestStringDecode()
{
Assert.AreEqual(
"Test",
Bottomify.DecodeString("πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")
);
Assert.AreEqual(
"Test",
Bottomify.DecodeString("πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")
);
Assert.AreEqual(
"Te\0st",
Bottomify.DecodeString("πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆβ€οΈπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")
);
}
[DataRow("Test", "πŸ’–βœ¨βœ¨βœ¨,,,,\u200BπŸ’–πŸ’–,\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί\u200BπŸ’–πŸ’–βœ¨πŸ₯Ί,\u200B")]
[DataRow("Test", "πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")]
[DataRow("Te\0st", "πŸ’–βœ¨βœ¨βœ¨,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–,πŸ‘‰πŸ‘ˆβ€οΈπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")]
public void TestStringDecode(string expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.DecodeString(input)
);


[TestMethod]
public void TestUnicodeStringEncode()
{
Assert.AreEqual(
"πŸ«‚βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ",
Bottomify.EncodeString("πŸ₯Ί")
);
Assert.AreEqual(
"πŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆ",
Bottomify.EncodeString("γŒγ‚“γ°γ‚Œ")
);
}
[DataRow("πŸ«‚βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ", "πŸ₯Ί")]
[DataRow("πŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆ", "γŒγ‚“γ°γ‚Œ")]
public void TestUnicodeStringEncode(string expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.EncodeString(input)
);


[TestMethod]
public void TestUnicodeStringDecode()
{
Assert.AreEqual(
"πŸ₯Ί",
Bottomify.DecodeString("πŸ«‚βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")
);
Assert.AreEqual(
"γŒγ‚“γ°γ‚Œ",
Bottomify.DecodeString(
"πŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆ"
)
);
}
[DataRow("πŸ₯Ί", "πŸ«‚βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨πŸ₯ΊπŸ‘‰πŸ‘ˆπŸ’–πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆ")]
[DataRow("γŒγ‚“γ°γ‚Œ", "πŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,,,,πŸ‘‰πŸ‘ˆ" +
"πŸ’–πŸ’–πŸ’–βœ¨βœ¨πŸ₯Ί,πŸ‘‰πŸ‘ˆπŸ«‚βœ¨βœ¨πŸ₯Ί,,πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆπŸ’–πŸ’–βœ¨βœ¨βœ¨βœ¨πŸ‘‰πŸ‘ˆ")]

public void TestUnicodeStringDecode(string expectedResult, string input) => Assert.AreEqual(
expectedResult,
Bottomify.DecodeString(input)
);
}
}
Loading

0 comments on commit 47b89ef

Please sign in to comment.