mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Fixed bugs in json due to recent commit (luckily unit tests failed)
This commit is contained in:
parent
1f0efb3885
commit
8407d4320d
@ -15,6 +15,7 @@
|
||||
* Fixed issue where it was not possible to move border in waveform
|
||||
* Fixed issue regarding alignment tags (like {\an8}) in Json - thx zatch
|
||||
|
||||
|
||||
3.3.13 (8th February 2014)
|
||||
* NEW:
|
||||
* Compare window now has an option to "ignore line breaks" - thx Krystian
|
||||
|
@ -40,7 +40,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
sb.Append("{\"duration\":");
|
||||
sb.Append(p.Duration.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"content\":\"");
|
||||
sb.Append(Json.EncodeJsonText(p.Text));
|
||||
sb.Append(Json.EncodeJsonText(p.Text) + "\"");
|
||||
sb.Append(",\"startOfParagraph\":false");
|
||||
sb.Append(",\"startTime\":");
|
||||
sb.Append(p.StartTime.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
|
@ -47,7 +47,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
sb.Append(",\"guid\":\"" + guid + "\",\"segmentTypeId\":\"" + segmentTypeId + "\",\"endTime\":");
|
||||
sb.Append(p.EndTime.TotalSeconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"id\":\"" + id + "\",\"metadata\":{\"Text\":\"");
|
||||
sb.Append(Json.EncodeJsonText(p.Text));
|
||||
sb.Append(Json.EncodeJsonText(p.Text) + "\"");
|
||||
|
||||
sb.Append(",\"ID\":\"\",\"Language\":\"en\"}}");
|
||||
count++;
|
||||
|
64
src/Test/BinaryOcrTest.cs
Normal file
64
src/Test/BinaryOcrTest.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Nikse.SubtitleEdit.Logic.OCR.Binary;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
[TestClass]
|
||||
public class BinaryOcrTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
string tempFileName = System.IO.Path.GetTempFileName();
|
||||
var db = new BinaryOcrDb(tempFileName);
|
||||
var nbmp = new NikseBitmap(2, 2);
|
||||
nbmp.SetPixel(0, 0, Color.Transparent);
|
||||
nbmp.SetPixel(1, 0, Color.Transparent);
|
||||
nbmp.SetPixel(1, 0, Color.Transparent);
|
||||
nbmp.SetPixel(1, 1, Color.White);
|
||||
|
||||
var bob = new BinaryOcrBitmap(nbmp);
|
||||
bob.Text = "Debug";
|
||||
db.CompareImages.Add(bob);
|
||||
|
||||
nbmp.SetPixel(0, 0, Color.White);
|
||||
var bob2 = new BinaryOcrBitmap(nbmp);
|
||||
bob2.Text = "tt";
|
||||
bob2.Italic = true;
|
||||
bob2.ExpandCount = 2;
|
||||
db.CompareImages.Add(bob2);
|
||||
db.Save();
|
||||
|
||||
db = new BinaryOcrDb(tempFileName, true);
|
||||
Assert.IsTrue(db.CompareImages.Count == 2);
|
||||
|
||||
Assert.IsTrue(bob.Width == db.CompareImages[0].Width);
|
||||
Assert.IsTrue(bob.Height == db.CompareImages[0].Height);
|
||||
Assert.IsTrue(bob.NumberOfColoredPixels == db.CompareImages[0].NumberOfColoredPixels);
|
||||
Assert.IsTrue(bob.Hash == db.CompareImages[0].Hash);
|
||||
Assert.IsTrue(bob.Italic == db.CompareImages[0].Italic);
|
||||
Assert.IsTrue(bob.ExpandCount == db.CompareImages[0].ExpandCount);
|
||||
Assert.IsTrue(bob.Text == db.CompareImages[0].Text);
|
||||
|
||||
Assert.IsTrue(bob2.Width == db.CompareImages[1].Width);
|
||||
Assert.IsTrue(bob2.Height == db.CompareImages[1].Height);
|
||||
Assert.IsTrue(bob2.NumberOfColoredPixels == db.CompareImages[1].NumberOfColoredPixels);
|
||||
Assert.IsTrue(bob2.Hash == db.CompareImages[1].Hash);
|
||||
Assert.IsTrue(bob2.Italic == db.CompareImages[1].Italic);
|
||||
Assert.IsTrue(bob2.ExpandCount == db.CompareImages[1].ExpandCount);
|
||||
Assert.IsTrue(bob2.Text == db.CompareImages[1].Text);
|
||||
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(tempFileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
System.IO.File.Delete(tempFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
src/Test/UtilitiesTest.cs
Normal file
30
src/Test/UtilitiesTest.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
[TestClass]
|
||||
public class UtilitiesTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void AutoBreakLine1()
|
||||
{
|
||||
const int maxLength = 43;
|
||||
var s = Utilities.AutoBreakLine("You have a private health insurance and life insurance." + Environment.NewLine + "A digital clone included.", 5, maxLength, 33);
|
||||
var arr = s.Replace(Environment.NewLine, "\n").Split('\n');
|
||||
Assert.AreEqual(2, arr.Length);
|
||||
Assert.IsFalse(arr[0].Length > maxLength);
|
||||
Assert.IsFalse(arr[1].Length > maxLength);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AutoBreakLine2()
|
||||
{
|
||||
const int maxLength = 43;
|
||||
var s = Utilities.AutoBreakLine("- We're gonna lose him." + Environment.NewLine + "- He's left him four signals in the last week.", 5, maxLength, 33);
|
||||
Assert.IsFalse(s == "- We're gonna lose him." + Environment.NewLine + "- He's left him four signals in the last week.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user