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

Feature/cross platform line break #9175

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use Environment.NewLine in test assertions for consistency.
Replaced hardcoded line-break strings with Environment.NewLine in test assertions to ensure consistency across different environments. This change improves code readability and reduces potential issues with platform-specific line endings.
ivandrofly committed Jan 5, 2025
commit 404e6385f59a8ff982d3a6a8b0267f88cf9a331a
10 changes: 5 additions & 5 deletions src/Tests/Logic/SplitLongLinesHelperTest.cs
Original file line number Diff line number Diff line change
@@ -49,8 +49,8 @@ public void SplitLongLinesInSubtitleTest()
Configuration.Settings.Tools.AutoBreakUsePixelWidth = false;
var procSubtitle = SplitLongLinesHelper.SplitLongLinesInSubtitle(_subtitle, _maxLineLength * 2, _maxLineLength);

Assert.AreEqual("We have never been to Asia,\r\nnor have we visited Africa.", procSubtitle.Paragraphs[0].Text);
Assert.AreEqual("We have never\r\nbeen to Asia, nor\r\nhave we visited Africa.", procSubtitle.Paragraphs[1].Text);
Assert.AreEqual($"We have never been to Asia,{Environment.NewLine}nor have we visited Africa.", procSubtitle.Paragraphs[0].Text);
Assert.AreEqual($"We have never{Environment.NewLine}been to Asia, nor{Environment.NewLine}have we visited Africa.", procSubtitle.Paragraphs[1].Text);
Assert.AreEqual(_subtitle.Paragraphs[2].Text, procSubtitle.Paragraphs[2].Text);

Assert.AreNotEqual(_subtitle.Paragraphs.Count, procSubtitle.Paragraphs.Count);
@@ -60,8 +60,8 @@ public void SplitLongLinesInSubtitleTest()
Assert.AreEqual(Utilities.AutoBreakLine("Of yourself and laugh it off to realise that life isn’t so bad after all.", "en"), procSubtitle.Paragraphs[4].Text);

// too long
Assert.AreEqual("Sometimes, all you need to do is\r\ncompletely make an ass of yourself", procSubtitle.Paragraphs[5].Text);
Assert.AreEqual("and laugh it off to realise that\r\nlife isn’t so bad after all.", procSubtitle.Paragraphs[6].Text);
Assert.AreEqual($"Sometimes, all you need to do is{Environment.NewLine}completely make an ass of yourself", procSubtitle.Paragraphs[5].Text);
Assert.AreEqual($"and laugh it off to realise that{Environment.NewLine}life isn’t so bad after all.", procSubtitle.Paragraphs[6].Text);

// timing test
if (procSubtitle.Paragraphs[5].DurationTotalMilliseconds > procSubtitle.Paragraphs[6].DurationTotalMilliseconds)
@@ -88,7 +88,7 @@ public void SplitLongLinesInSubtitleTest2()
[TestMethod]
public void MillisecondsPerCharTest()
{
string text = Utilities.AutoBreakLine("The waves were crashing on the\r\nshore; it was a lovely sight.");
string text = Utilities.AutoBreakLine($"The waves were crashing on the{Environment.NewLine}shore; it was a lovely sight.");
double optimalDuration = Utilities.GetOptimalDisplayMilliseconds(text);
double displayCharLen = HtmlUtil.RemoveHtmlTags(text, true).Length - (Utilities.GetNumberOfLines(text) - 1) * Environment.NewLine.Length;
double msPerChar = optimalDuration / displayCharLen;