Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sakapon/v1.1
v1.1.6
- Loading branch information
Showing
30 changed files
with
561 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Zipangu; | ||
|
||
namespace NetUnitTest | ||
{ | ||
[TestClass] | ||
public class EncodingHelperTest | ||
{ | ||
[TestMethod] | ||
public void ShiftJIS() | ||
{ | ||
var actual = EncodingHelper.ShiftJIS; | ||
Assert.AreEqual(932, actual.CodePage); | ||
Assert.AreEqual("shift_jis", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void ISO2022JP() | ||
{ | ||
var actual = EncodingHelper.ISO2022JP; | ||
Assert.AreEqual(50220, actual.CodePage); | ||
Assert.AreEqual("iso-2022-jp", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void EUCJP() | ||
{ | ||
var actual = EncodingHelper.EUCJP; | ||
Assert.AreEqual(51932, actual.CodePage); | ||
Assert.AreEqual("euc-jp", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void ShiftJIS_GetString() | ||
{ | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 188, 172, 151, 144, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.ShiftJIS.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.ShiftJIS.GetBytes(text)); | ||
} | ||
|
||
[TestMethod] | ||
public void ISO2022JP_GetString() | ||
{ | ||
// 半角カタカナは存在しません。 | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 27, 36, 66, 37, 55, 37, 99, 77, 112, 27, 40, 66, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.ISO2022JP.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.ISO2022JP.GetBytes(text)); | ||
} | ||
|
||
[TestMethod] | ||
public void EUCJP_GetString() | ||
{ | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 142, 188, 142, 172, 205, 240, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.EUCJP.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.EUCJP.GetBytes(text)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Zipangu; | ||
|
||
namespace UnitTest | ||
{ | ||
[TestClass] | ||
public class EncodingHelperTest | ||
{ | ||
[TestMethod] | ||
public void ShiftJIS() | ||
{ | ||
var actual = EncodingHelper.ShiftJIS; | ||
Assert.AreEqual(932, actual.CodePage); | ||
Assert.AreEqual("shift_jis", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void ISO2022JP() | ||
{ | ||
var actual = EncodingHelper.ISO2022JP; | ||
Assert.AreEqual(50220, actual.CodePage); | ||
Assert.AreEqual("iso-2022-jp", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void EUCJP() | ||
{ | ||
var actual = EncodingHelper.EUCJP; | ||
Assert.AreEqual(51932, actual.CodePage); | ||
Assert.AreEqual("euc-jp", actual.WebName); | ||
} | ||
|
||
[TestMethod] | ||
public void ShiftJIS_GetString() | ||
{ | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 188, 172, 151, 144, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.ShiftJIS.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.ShiftJIS.GetBytes(text)); | ||
} | ||
|
||
[TestMethod] | ||
public void ISO2022JP_GetString() | ||
{ | ||
// 半角カタカナは存在しません。 | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 27, 36, 66, 37, 55, 37, 99, 77, 112, 27, 40, 66, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.ISO2022JP.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.ISO2022JP.GetBytes(text)); | ||
} | ||
|
||
[TestMethod] | ||
public void EUCJP_GetString() | ||
{ | ||
var text = "シャ乱Q"; | ||
var bytes = new byte[] { 142, 188, 142, 172, 205, 240, 81 }; | ||
|
||
Assert.AreEqual(text, EncodingHelper.EUCJP.GetString(bytes)); | ||
CollectionAssert.AreEqual(bytes, EncodingHelper.EUCJP.GetBytes(text)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Zipangu\Zipangu.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.