mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix unit tests
This commit is contained in:
parent
6672501b83
commit
8c752fcb8a
@ -1459,7 +1459,7 @@ Continue?</SubtitleAppendPrompt>
|
||||
<BeforeSpellCheck>Before spell check</BeforeSpellCheck>
|
||||
<SpellCheckChangedXToY>Spell check: Changed '{0}' to '{1}'</SpellCheckChangedXToY>
|
||||
<BeforeAddingTagX>Before adding <{0}> tag</BeforeAddingTagX>
|
||||
<TagXAdded><{0}> tags added</TagXAdded>
|
||||
<TagXAdded>{0} tag added</TagXAdded>
|
||||
<LineXOfY>line {0} of {1}</LineXOfY>
|
||||
<XLinesSavedAsY>{0} lines saved as {1}</XLinesSavedAsY>
|
||||
<XLinesDeleted>{0} lines deleted</XLinesDeleted>
|
||||
@ -2362,6 +2362,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<MainTextBoxAutoBreakFromPosAndGoToNext>Break at first space from cursor position and go to next</MainTextBoxAutoBreakFromPosAndGoToNext>
|
||||
<MainTextBoxUnbreak>Unbreak text</MainTextBoxUnbreak>
|
||||
<MainTextBoxUnbreakNoSpace>Unbreak without space (CJK)</MainTextBoxUnbreakNoSpace>
|
||||
<MainTextBoxAssaIntellisense>Show ASSA intellisense</MainTextBoxAssaIntellisense>
|
||||
<MainFileSaveAll>Save all</MainFileSaveAll>
|
||||
<Miscellaneous>Misc.</Miscellaneous>
|
||||
<CpsIncludesSpace>Chars/sec (CPS) includes spaces</CpsIncludesSpace>
|
||||
|
@ -468,6 +468,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\i1}Italic{\i0}"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<i>Italic</i>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -479,6 +480,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\b1}Bold{\b0}"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<b>Bold</b>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -490,6 +492,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\u1}Underline{\u0}"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<u>Underline</u>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -501,6 +504,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fs28}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font size=\"28\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -512,6 +516,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fs1}T{\fs2}E{\fs3}S{\fs4}T"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font size=\"1\">T</font><font size=\"2\">E</font><font size=\"3\">S</font><font size=\"4\">T</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -533,6 +538,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fnArial}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font face=\"Arial\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -544,6 +550,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fnArial Bold}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font face=\"Arial Bold\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -564,6 +571,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fnArial}Font1{\fnTahoma}Font2"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font face=\"Arial\">Font1</font><font face=\"Tahoma\">Font2</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -575,6 +583,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\c&HFF&}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font color=\"#ff0000\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -586,6 +595,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\c&HFF00&}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font color=\"#00ff00\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -597,6 +607,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\c&HFF0000&}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font color=\"#0000ff\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -608,6 +619,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\c&HFFFFFF&}Font"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font color=\"#ffffff\">Font</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -619,6 +631,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"start {\c&HFFFFFF&}Font end"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "start <font color=\"#ffffff\">Font end</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -630,6 +643,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"start {\1c&HFFFF00&\i1}CYAN{\i0}{\1c} end"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "start <font color=\"#00ffff\"><i>CYAN</i></font> end";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -641,6 +655,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\i1\c&H00ffff&}Italic and color{\c}{\i0}"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
var actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<i><font color=\"#ffff00\">Italic and color</font></i>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -652,6 +667,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"start {\1c&HFFFF00&\i1}CYAN{\i0} end"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "start <font color=\"#00ffff\"><i>CYAN</i> end</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -663,6 +679,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"start {\fnFont Name}text1 {\fs10}text2{\fs}{\fn} {\1c&H112233}text3{\1c} text4 {\c&332211}text5{\c} end"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "start <font face=\"Font Name\">text1 <font size=\"10\">text2</font></font> <font color=\"#332211\">text3</font> text4 <font color=\"#112233\">text5</font> end";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -674,6 +691,7 @@ Dialogue: 0,0:00:16.84,0:00:18.16,rechts,,0000,0000,0000,," + lineOneText;
|
||||
var target = new AdvancedSubStationAlpha();
|
||||
var subtitle = new Subtitle();
|
||||
target.LoadSubtitle(subtitle, GetAssLines(@"{\fnViner Hand ITC\fs28}Testing"), null);
|
||||
target.RemoveNativeFormatting(subtitle, new SubRip());
|
||||
string actual = subtitle.Paragraphs[0].Text;
|
||||
const string expected = "<font face=\"Viner Hand ITC\" size=\"28\">Testing</font>";
|
||||
Assert.AreEqual(expected, actual);
|
||||
@ -1143,18 +1161,21 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
|
||||
subtitle.Paragraphs.Add(new Paragraph("Line 4", 12000, 15000));
|
||||
|
||||
int expected = subtitle.Paragraphs.Count;
|
||||
foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats)
|
||||
foreach (var format in SubtitleFormat.AllSubtitleFormats)
|
||||
{
|
||||
if (format.GetType() != typeof(JsonType6) && format.IsTextBased)
|
||||
{
|
||||
format.BatchMode = true;
|
||||
string text = format.ToText(subtitle, "test");
|
||||
var text = format.ToText(subtitle, "test");
|
||||
var list = new List<string>();
|
||||
foreach (string line in text.Replace("\r\n", "\n").Split('\n'))
|
||||
foreach (var line in text.Replace("\r\n", "\n").Split('\n'))
|
||||
{
|
||||
list.Add(line);
|
||||
}
|
||||
|
||||
var s2 = new Subtitle();
|
||||
format.LoadSubtitle(s2, list, null);
|
||||
int actual = s2.Paragraphs.Count;
|
||||
var actual = s2.Paragraphs.Count;
|
||||
Assert.AreEqual(expected, actual, format.FriendlyName);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
private static string EncodeTimeCode(TimeCode time)
|
||||
{
|
||||
return time.ToDisplayString().Replace(",", ".");
|
||||
return time.ToString().Replace(",", ".");
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
@ -37,7 +37,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
_errorCount = 0;
|
||||
foreach (string line in lines)
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var s = line.Trim();
|
||||
if (s.StartsWith("CHAPTER", StringComparison.Ordinal))
|
||||
|
@ -40,8 +40,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
|
||||
var start = p.StartTime.ToDisplayString().Replace(",", ".");
|
||||
var end = p.EndTime.ToDisplayString().Replace(",", ".");
|
||||
var start = p.StartTime.ToString().Replace(",", ".");
|
||||
var end = p.EndTime.ToString().Replace(",", ".");
|
||||
var text = HtmlUtil.RemoveHtmlTags(p.Text, true);
|
||||
sb.AppendLine(string.Format(writeFormat, start, end, Environment.NewLine, text, count));
|
||||
}
|
||||
|
@ -6496,6 +6496,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Settings/MainTextBoxUnbreakNoSpace":
|
||||
language.Settings.MainTextBoxUnbreakNoSpace = reader.Value;
|
||||
break;
|
||||
case "Settings/MainTextBoxAssaIntellisense":
|
||||
language.Settings.MainTextBoxAssaIntellisense = reader.Value;
|
||||
break;
|
||||
case "Settings/MainFileSaveAll":
|
||||
language.Settings.MainFileSaveAll = reader.Value;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user