diff --git a/src/Changelog.txt b/src/Changelog.txt index d54f10342..225b6bae5 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -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 diff --git a/src/Logic/SubtitleFormats/JsonType3.cs b/src/Logic/SubtitleFormats/JsonType3.cs index 9e5459601..e35142bb5 100644 --- a/src/Logic/SubtitleFormats/JsonType3.cs +++ b/src/Logic/SubtitleFormats/JsonType3.cs @@ -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)); diff --git a/src/Logic/SubtitleFormats/JsonType4.cs b/src/Logic/SubtitleFormats/JsonType4.cs index c2ddf5f9b..219262a9f 100644 --- a/src/Logic/SubtitleFormats/JsonType4.cs +++ b/src/Logic/SubtitleFormats/JsonType4.cs @@ -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++; diff --git a/src/Test/BinaryOcrTest.cs b/src/Test/BinaryOcrTest.cs new file mode 100644 index 000000000..788b133e4 --- /dev/null +++ b/src/Test/BinaryOcrTest.cs @@ -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); + } + } + } +} diff --git a/src/Test/UtilitiesTest.cs b/src/Test/UtilitiesTest.cs new file mode 100644 index 000000000..0286ca071 --- /dev/null +++ b/src/Test/UtilitiesTest.cs @@ -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."); + } + + } +}