Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 1a44ece

Browse files
AlexRadchPaulo Janotti
authored andcommitted
Fixed netfx System.Xml.Linq.xNodeBuilder.Tests fails on non English Windows (#28183)
* Fixed netfex System.Xml.Linq.xNodeBuilder.Tests fails on non English Windows. * Added comments
1 parent 8924709 commit 1a44ece

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Globalization;
1010
using System.Collections;
1111
using System.Collections.Generic;
12+
using System.Text.RegularExpressions;
1213
using System.Xml;
1314
using System.Xml.Linq;
1415
using System.Xml.XmlDiff;
@@ -3418,8 +3419,12 @@ public void WriteCDataWithTwoClosingBrackets_5()
34183419
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
34193420
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
34203421
{
3421-
string expectedMsg = "Cannot have ']]>' inside an XML CDATA block.";
3422-
Assert.Equal(expectedMsg, exception.Message);
3422+
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
3423+
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
3424+
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
3425+
Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("]]>") + @"[\p{Pf}\p{Po}]"));
3426+
Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
3427+
Assert.True(Regex.IsMatch(exception.Message, @"\b" + "CDATA" + @"\b"));
34233428
}
34243429
}
34253430
}
@@ -3612,8 +3617,13 @@ public void WriteCommentWithDoubleHyphensInValue()
36123617
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
36133618
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
36143619
{
3615-
string expectedMsg = "An XML comment cannot contain '--', and '-' cannot be the last character.";
3616-
Assert.Equal(expectedMsg, exception.Message);
3620+
// \b word boundary
3621+
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
3622+
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
3623+
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
3624+
Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
3625+
Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("--") + @"[\p{Pf}\p{Po}]"));
3626+
Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("-") + @"[\p{Pf}\p{Po}]"));
36173627
}
36183628
}
36193629
}
@@ -4215,8 +4225,12 @@ public void IncludePIEndTagAsPartOfTextValue()
42154225
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
42164226
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
42174227
{
4218-
string expectedMsg = "Cannot have '?>' inside an XML processing instruction.";
4219-
Assert.Equal(expectedMsg, exception.Message);
4228+
// \b word boundary
4229+
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
4230+
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
4231+
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
4232+
Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("?>") + @"[\p{Pf}\p{Po}]"));
4233+
Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
42204234
}
42214235
}
42224236
}

0 commit comments

Comments
 (0)