From aa6c474999953692b4974c92caabe54fa6515616 Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:35:01 -0400 Subject: [PATCH] Changed tests to explicitly assert for strings with \r\n As opposed to leaving it up to the IDE to decide at compile time by having newlines in the actual document --- .../Bson/BsonReaderTests.cs | 12 +--- Src/Newtonsoft.Json.Tests/JsonConvertTest.cs | 6 +- .../JsonTextReaderTest.cs | 60 +------------------ .../JsonTextWriterTest.cs | 3 +- 4 files changed, 7 insertions(+), 74 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 73aa7d34..962ccb68 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -808,10 +808,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"for (int i = 0; i < 1000; i++) -{ - alert(arg1); -}", reader.Value); + Assert.AreEqual("for (int i = 0; i < 1000; i++)\r\n{\r\n alert(arg1);\r\n}", reader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); @@ -1299,12 +1296,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

- -

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

- -

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

-", reader.Value); + Assert.AreEqual("

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

\r\n\r\n

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

\r\n\r\n

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

\r\n", reader.Value); Assert.AreEqual(typeof(string), reader.ValueType); Assert.IsTrue(reader.Read()); diff --git a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs index 9ad0f186..d3b7df11 100644 --- a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs @@ -342,8 +342,7 @@ namespace Newtonsoft.Json.Tests result = JavaScriptUtils.ToEscapedJavaScriptString("How now cow?", '"', true); Assert.AreEqual(@"""How now cow?""", result); - result = JavaScriptUtils.ToEscapedJavaScriptString(@"How -now brown cow?", '"', true); + result = JavaScriptUtils.ToEscapedJavaScriptString("How \r\nnow brown cow?", '"', true); Assert.AreEqual(@"""How \r\nnow brown cow?""", result); result = JavaScriptUtils.ToEscapedJavaScriptString("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007", '"', true); @@ -576,8 +575,7 @@ now brown cow?", '"', true); [Test] public void StringEscaping() { - string v = @"It's a good day -""sunshine"""; + string v = "It's a good day\r\n\"sunshine\""; string json = JsonConvert.ToString(v); Assert.AreEqual(@"""It's a good day\r\n\""sunshine\""""", json); diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index afa3071f..a92affb6 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -344,62 +344,7 @@ third line", jsonTextReader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"#C16------------------------------ -#C12Ingredients #C20 -#C16------------------------------ - -a piece of Leather Armor -( ie #L ""Enhanced Leather Armor Boots"" ""85644"" ) - - -#L ""Hacker Tool"" ""87814"" - - -#L ""Clanalizer"" ""208313"" - - -#C16------------------------------ -#C12Recipe #C16 -#C16------------------------------#C20 - -Hacker Tool -#C15+#C20 -a piece of Leather Armor -#C15=#C20 - -a piece of Hacked Leather Armor -( ie : #L ""Hacked Leather Armor Boots"" ""245979"" ) -#C16Skills: | BE |#C20 - -#C14------------------------------#C20 - -Clanalizer -#C15+#C20 -a piece of Hacked Leather Armor -#C15=#C20 - -a piece of Apocalypse Leather Armor -( ie : #L ""Apocalypse Leather Armor Boots"" ""245966"" ) -#C16Skills: | ?? |#C20 - -#C16------------------------------ -#C12Details#C16 -#C16------------------------------#C20 - -#L ""Apocalypse Leather Armor Boots"" ""245967"" -#L ""Apocalypse Leather Armor Gloves"" ""245969"" -#L ""Apocalypse Leather Armor Helmet"" ""245975"" -#L ""Apocalypse Leather Armor Pants"" ""245971"" -#L ""Apocalypse Leather Armor Sleeves"" ""245973"" -#L ""Apocalypse Leather Body Armor"" ""245965"" - -#C16------------------------------ -#C12Comments#C16 -#C16------------------------------#C20 - -Nice froob armor.. but ugleh! - -", reader.Value); + Assert.AreEqual("#C16------------------------------\r\n#C12Ingredients #C20\r\n#C16------------------------------\r\n\r\na piece of Leather Armor\r\n( ie #L \"Enhanced Leather Armor Boots\" \"85644\" )\r\n\r\n\r\n#L \"Hacker Tool\" \"87814\"\r\n\r\n\r\n#L \"Clanalizer\" \"208313\"\r\n\r\n\r\n#C16------------------------------\r\n#C12Recipe #C16\r\n#C16------------------------------#C20\r\n\r\nHacker Tool\r\n#C15+#C20\r\na piece of Leather Armor\r\n#C15=#C20\r\n\r\na piece of Hacked Leather Armor\r\n( ie : #L \"Hacked Leather Armor Boots\" \"245979\" )\r\n#C16Skills: | BE |#C20\r\n\r\n#C14------------------------------#C20\r\n\r\nClanalizer\r\n#C15+#C20\r\na piece of Hacked Leather Armor\r\n#C15=#C20\r\n\r\na piece of Apocalypse Leather Armor\r\n( ie : #L \"Apocalypse Leather Armor Boots\" \"245966\" )\r\n#C16Skills: | ?? |#C20\r\n\r\n#C16------------------------------\r\n#C12Details#C16\r\n#C16------------------------------#C20\r\n\r\n#L \"Apocalypse Leather Armor Boots\" \"245967\"\r\n#L \"Apocalypse Leather Armor Gloves\" \"245969\"\r\n#L \"Apocalypse Leather Armor Helmet\" \"245975\"\r\n#L \"Apocalypse Leather Armor Pants\" \"245971\"\r\n#L \"Apocalypse Leather Armor Sleeves\" \"245973\"\r\n#L \"Apocalypse Leather Body Armor\" \"245965\"\r\n\r\n#C16------------------------------\r\n#C12Comments#C16\r\n#C16------------------------------#C20\r\n\r\nNice froob armor.. but ugleh!\r\n\r\n", reader.Value); } [Test] @@ -1272,8 +1217,7 @@ Parameter name: reader", Assert.IsTrue(reader.Read()); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); - Assert.AreEqual(@"hi -bye", reader.Value); + Assert.AreEqual("hi\r\nbye", reader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.Integer, reader.TokenType); Assert.AreEqual(1L, reader.Value); diff --git a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs index d8bafe89..d6d81c98 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs @@ -261,8 +261,7 @@ namespace Newtonsoft.Json.Tests jsonWriter.WriteStartArray(); jsonWriter.WriteValue(@"""These pretzels are making me thirsty!"""); jsonWriter.WriteValue("Jeff's house was burninated."); - jsonWriter.WriteValue(@"1. You don't talk about fight club. -2. You don't talk about fight club."); + jsonWriter.WriteValue("1. You don't talk about fight club.\r\n2. You don't talk about fight club."); jsonWriter.WriteValue("35% of\t statistics\n are made\r up."); jsonWriter.WriteEndArray(); }