Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big-endian test case fixes: XML #49689

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5755,7 +5755,14 @@ public void BinHex_9(XmlWriterUtils utils)
w.WriteBinHex(Wbase64, 0, (int)Wbase64len);
w.WriteEndElement();
}
Assert.True(utils.CompareReader("<root a='610062006300' />"));
if (System.BitConverter.IsLittleEndian)
{
Assert.True(utils.CompareReader("<root a='610062006300' />"));
}
else
{
Assert.True(utils.CompareReader("<root a='006100620063' />"));
}
}

// Call WriteBinHex and verify results can be read as a string
Expand All @@ -5777,7 +5784,14 @@ public void BinHex_10(XmlWriterUtils utils)
w.WriteBinHex(Wbase64, 0, (int)Wbase64len);
w.WriteEndElement();
}
Assert.True(utils.CompareReader("<root>610062006300</root>"));
if (System.BitConverter.IsLittleEndian)
{
Assert.True(utils.CompareReader("<root>610062006300</root>"));
}
else
{
Assert.True(utils.CompareReader("<root>006100620063</root>"));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand Down Expand Up @@ -47,7 +48,8 @@ public int v3()
string strUni = string.Empty;
for (int i = 0; i < _dbyte.Length; i = i + 2)
{
strUni += (BitConverter.ToChar(_dbyte, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_dbyte, i, 2));
strUni += c.ToString();
}
CError.WriteLine(strUni + " " + XmlConvert.EncodeName(strUni));
CError.Compare(XmlConvert.EncodeName(strUni), "_xFF71_", "EncodeName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName4()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_BaseChar, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_BaseChar, i, 2));
strEnVal = XmlConvert.EncodeName(c.ToString());
CError.Compare(strEnVal, _Expbyte_BaseChar[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName5()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_BaseChar, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_BaseChar, i, 2));
strEnVal = XmlConvert.EncodeNmToken(c.ToString());

if (_Expbyte_BaseChar[i / 2] != "_x0387_" && _Expbyte_BaseChar[i / 2] != "_x0640_" && _Expbyte_BaseChar[i / 2] != "_x064B_" && _Expbyte_BaseChar[i / 2] != "_x0670_" && _Expbyte_BaseChar[i / 2] != "_x06D6_" && _Expbyte_BaseChar[i / 2] != "_x06E4_" && _Expbyte_BaseChar[i / 2] != "_x06E7_" && _Expbyte_BaseChar[i / 2] != "_x093C_" && _Expbyte_BaseChar[i / 2] != "_x093E_" && _Expbyte_BaseChar[i / 2] != "_x0962_" && _Expbyte_BaseChar[i / 2] != "_x09E2_" && _Expbyte_BaseChar[i / 2] != "_x09EF_" && _Expbyte_BaseChar[i / 2] != "_x0A71_" && _Expbyte_BaseChar[i / 2] != "_x0ABC_" && _Expbyte_BaseChar[i / 2] != "_x0ABE_" && _Expbyte_BaseChar[i / 2] != "_x0B3C_" && _Expbyte_BaseChar[i / 2] != "_x0B3E_" && _Expbyte_BaseChar[i / 2] != "_x0E31_" && _Expbyte_BaseChar[i / 2] != "_x0E34_" && _Expbyte_BaseChar[i / 2] != "_x0E46_" && _Expbyte_BaseChar[i / 2] != "_x0EB1_" && _Expbyte_BaseChar[i / 2] != "_x0EB4_" && _Expbyte_BaseChar[i / 2] != "_x0EBC_" && _Expbyte_BaseChar[i / 2] != "_x0F3F_")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -28,7 +29,8 @@ public int XmlEncodeName6()
string strDeVal = string.Empty;
string strVal = string.Empty;

strVal = (BitConverter.ToChar(_byte_BaseChar, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_BaseChar, i, 2));
strVal = c.ToString();
strEnVal = XmlConvert.EncodeName(strVal);
CError.Compare(strEnVal, _Expbyte_BaseChar[i / 2], "Encode Comparison failed at " + i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName1()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_CombiningChar, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_CombiningChar, i, 2));
strEnVal = XmlConvert.EncodeName(c.ToString());
CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName2()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_CombiningChar, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_CombiningChar, i, 2));
strEnVal = XmlConvert.EncodeNmToken(c.ToString());
if (_Expbyte_CombiningChar[i / 2] != "_x0A6F_" && _Expbyte_CombiningChar[i / 2] != "_x0E46_")
{
CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Comparison failed at " + i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -28,7 +29,8 @@ public int XmlEncodeName3()
string strEnVal = string.Empty;
string strVal = string.Empty;

strVal = (BitConverter.ToChar(_byte_CombiningChar, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_CombiningChar, i, 2));
strVal = c.ToString();
strEnVal = XmlConvert.EncodeName(strVal);
CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Encode Comparison failed at " + i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName1()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_Digit, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Digit, i, 2));
strEnVal = XmlConvert.EncodeName(c.ToString());
CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName2()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_Digit, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Digit, i, 2));
strEnVal = XmlConvert.EncodeNmToken(c.ToString());
if (_Expbyte_Digit[i / 2] != "_x0A70_")
{
CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Comparison failed at " + i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -28,7 +29,8 @@ public int XmlEncodeName3()
string strEnVal = string.Empty;
string strVal = string.Empty;

strVal = (BitConverter.ToChar(_byte_Digit, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Digit, i, 2));
strVal = c.ToString();
strEnVal = XmlConvert.EncodeName(strVal);
CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Encode Comparison failed at " + i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName1()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_EmbeddedNull, i, 2));
strEnVal = XmlConvert.EncodeName(c.ToString());
CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName2()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_EmbeddedNull, i, 2));
strEnVal = XmlConvert.EncodeNmToken(c.ToString());
CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -28,7 +29,8 @@ public int XmlEncodeName3()
string strEnVal = string.Empty;
string strVal = string.Empty;

strVal = (BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_EmbeddedNull, i, 2));
strVal = c.ToString();
strEnVal = XmlConvert.EncodeName(strVal);
CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Encode Comparison failed at " + i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_Ideographic, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Ideographic, i, 2));
strEnVal = XmlConvert.EncodeName(c.ToString());
CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Comparison failed at " + i);
return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -26,7 +27,8 @@ public int XmlEncodeName()
int i = ((CurVariation.id) - 1) * 2;
string strEnVal = string.Empty;

strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_Ideographic, i)).ToString());
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Ideographic, i, 2));
strEnVal = XmlConvert.EncodeNmToken(c.ToString());
if (_Expbyte_Ideographic[i / 2] != "_x302A_")
{
CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Comparison failed at " + i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using OLEDB.Test.ModuleCore;
using System.Buffers.Binary;

namespace System.Xml.Tests
{
Expand All @@ -28,7 +29,8 @@ public int XmlEncodeName()
string strEnVal = string.Empty;
string strVal = string.Empty;

strVal = (BitConverter.ToChar(_byte_Ideographic, i)).ToString();
char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span<byte>(_byte_Ideographic, i, 2));
strVal = c.ToString();
strEnVal = XmlConvert.EncodeName(strVal);
CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Encode Comparison failed at " + i);

Expand Down