mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-07-08 18:16:25 +00:00
Fix consecutive empty line logic
This commit is contained in:
@@ -848,25 +848,25 @@ namespace SabreTools.RedumpLib.Test
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveConsecutiveNewlines
|
||||
#region RemoveConsecutiveEmptyLines
|
||||
|
||||
[Fact]
|
||||
public void RemoveConsecutiveNewlines_Linux_Removed()
|
||||
public void RemoveConsecutiveEmptyLines_Linux_Removed()
|
||||
{
|
||||
string expected = "data\nbase";
|
||||
string expected = "data\n\nbase";
|
||||
string newlines = "data\n\n\n\n\n\n\n\n\n\nbase";
|
||||
|
||||
string actual = Formatter.RemoveConsecutiveNewlines(newlines);
|
||||
string actual = Formatter.RemoveConsecutiveEmptyLines(newlines);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveConsecutiveNewlines_Windows_Removed()
|
||||
public void RemoveConsecutiveEmptyLines_Windows_Removed()
|
||||
{
|
||||
string expected = "data\r\nbase";
|
||||
string expected = "data\r\n\r\nbase";
|
||||
string newlines = "data\r\n\r\n\r\n\r\n\r\nbase";
|
||||
|
||||
string actual = Formatter.RemoveConsecutiveNewlines(newlines);
|
||||
string actual = Formatter.RemoveConsecutiveEmptyLines(newlines);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace SabreTools.RedumpLib
|
||||
status = "Formatting complete!";
|
||||
|
||||
// Make sure there aren't any instances of two blank lines in a row
|
||||
return RemoveConsecutiveNewlines(output.ToString());
|
||||
return RemoveConsecutiveEmptyLines(output.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -754,10 +754,10 @@ namespace SabreTools.RedumpLib
|
||||
/// <summary>
|
||||
/// Make sure there aren't any instances of two blank lines in a row
|
||||
/// </summary>
|
||||
internal static string RemoveConsecutiveNewlines(string str)
|
||||
internal static string RemoveConsecutiveEmptyLines(string str)
|
||||
{
|
||||
str = Regex.Replace(str, @"(\r\n)+", "\r\n");
|
||||
return Regex.Replace(str, @"(\n)+", "\n");
|
||||
str = Regex.Replace(str, @"(\r\n){2,}", "\r\n\r\n");
|
||||
return Regex.Replace(str, @"(\n){2,}", "\n\n");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user