Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#4 #10

Merged
merged 10 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Epub/KoeBook.Epub/Utility/ScrapingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public static class ScrapingHelper
{
public static List<string> SplitBrace(string text)
{
if (text.Length == 1 && text != "「" && text != "」")
if (text.Length == 1 && (text == "「" || text == "」"))
return [text];

var bracket = 0;
Expand Down
36 changes: 36 additions & 0 deletions KoeBook.Test/Epub/ScrapingHelperTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using KoeBook.Epub.Utility;

namespace KoeBook.Test.Epub;

public class ScrapingHelperTest
{
public static IEnumerable<object[]> Data()
{
yield return new object[] { "「", new List<string> { "「" } };
miyaji255 marked this conversation as resolved.
Show resolved Hide resolved
yield return new object[] { "」", new List<string> { "」" } };
yield return new object[] { "a", new List<string> { "a" } };
yield return new object[] { "abc「abc」abc", new List<string> { "abc", "「abc」", "abc" } };
yield return new object[] { "abc「abc」", new List<string> { "abc", "「abc」" } };
yield return new object[] { "「abc」abc", new List<string> { "「abc」", "abc", } };
yield return new object[] { "abc「abc」", new List<string> { "abc", "「abc」" } };
yield return new object[] { "「abc」", new List<string> { "「abc」", } };
yield return new object[] { "abc「abc", new List<string> { "abc", "「abc" } };
yield return new object[] { "abc「", new List<string> { "abc", "「" } };
yield return new object[] { "「abc", new List<string> { "「abc" } };
yield return new object[] { "abc」abc", new List<string> { "abc」", "abc" } };
yield return new object[] { "abc」", new List<string> { "abc」" } };
yield return new object[] { "」abc", new List<string> { "」", "abc" } };
yield return new object[] { "abc「abc」abc「abc」abc", new List<string> { "abc", "「abc」", "abc", "「abc」", "abc" } };
yield return new object[] { "「abc」abc「abc」abc", new List<string> { "「abc」", "abc", "「abc」", "abc" } };
yield return new object[] { "abc「abc」「abc」abc", new List<string> { "abc", "「abc」", "「abc」", "abc" } };
yield return new object[] { "abc「abc」abc「abc」", new List<string> { "abc", "「abc」", "abc", "「abc」" } };
miyaji255 marked this conversation as resolved.
Show resolved Hide resolved
}

[Theory]
[MemberData(nameof(Data))]
public void SplitBraceTest(string text, List<string> expected)
{
Assert.Equal(expected, ScrapingHelper.SplitBrace(text));

}
}
10 changes: 0 additions & 10 deletions KoeBook.Test/UnitTest1.cs

This file was deleted.

Loading