mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Minor refact + unit tests
This commit is contained in:
parent
85d2aca40c
commit
8e7a395a00
@ -1792,14 +1792,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
int hours = int.Parse(highPart.Substring(0, 4));
|
||||
int minutes = int.Parse(highPart.Substring(4, 2));
|
||||
int second = int.Parse(lowPart.Substring(2, 2));
|
||||
int seconds = int.Parse(lowPart.Substring(2, 2));
|
||||
int frames = int.Parse(lowPart.Substring(4, 2));
|
||||
|
||||
int milliseconds = (int)((TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * frames);
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(hours, minutes, second, milliseconds);
|
||||
return new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
return new TimeCode(0, 0, 0, 0);
|
||||
}
|
||||
|
@ -35,6 +35,29 @@ namespace Test.Logic
|
||||
Assert.AreEqual(0, p.NumberOfLines);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAdjust1()
|
||||
{
|
||||
var p = new Paragraph { Text = string.Empty, StartTime = new TimeCode(0,1,1,1) };
|
||||
p.Adjust(1, 10);
|
||||
Assert.AreEqual(new TimeCode(0,1,11,1).TotalMilliseconds, p.StartTime.TotalMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAdjust2()
|
||||
{
|
||||
var p = new Paragraph { Text = string.Empty, StartTime = new TimeCode(0, 1, 1, 1) };
|
||||
p.Adjust(2, 10);
|
||||
Assert.AreEqual(new TimeCode(0, 2, 12, 2).TotalMilliseconds, p.StartTime.TotalMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAdjust3()
|
||||
{
|
||||
var p = new Paragraph { Text = string.Empty, StartTime = new TimeCode(0, 0, 0, 0) };
|
||||
p.Adjust(1, 1);
|
||||
Assert.AreEqual(1, p.StartTime.TotalSeconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user