Skip to content

Commit

Permalink
bugfix in RelativePath.ParseName(..): update variable last for loop i… (
Browse files Browse the repository at this point in the history
#1330)

* bugfix in RelativePath.ParseName(..): update variable last for loop increment statement to keep it for further processing
  • Loading branch information
tobiasdroessler committed Mar 24, 2021
1 parent be1aade commit d9498f5
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Stack/Opc.Ua.Core/Types/Utils/RelativePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,8 @@ public static Element Parse(StringReader reader)

int last = reader.Peek();

for (int next = last; next != -1; next = reader.Peek())
for (int next = last; next != -1; next = reader.Peek(), last=next)
{
last = next;

if (!Char.IsDigit((char)next))
{
if (next == ':')
Expand Down
72 changes: 71 additions & 1 deletion Tests/Opc.Ua.Core.Tests/Types/Utils/UtilTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Opc.Ua.Core.Tests.Types.UtilsTests
[Parallelizable]
public class UtilsTests
{
#region Test Methods
#region misc
/// <summary>
/// Convert to and from little endian hex string.
/// </summary>
Expand Down Expand Up @@ -87,6 +87,76 @@ public void ToHexBigEndian()
var hexutil = Utils.ToHexString(blob, true);
Assert.AreEqual(hex, hexutil);
}

#endregion

#region RelativePath.Parse
/// <summary>
/// parse simple plain path string containing only numeric chars.
/// </summary>
[Test]
public void RelativePathParseNumericStringNonDeep()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/11";
Assert.AreEqual(str,RelativePath.Parse(str, typeTable).Format(typeTable));
}

/// <summary>
/// parse deep path string containing only numeric chars.
/// </summary>
[Test]
public void RelativePathParseNumericStringDeepPath()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/123/789";
Assert.AreEqual(str,RelativePath.Parse(str, typeTable).Format(typeTable));
}

/// <summary>
/// parse deep path string containing alphanumeric chars, staring with numeric chars.
/// </summary>
[Test]
public void RelativePathParseAlphanumericStringPath()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/123A/78B9";
Assert.AreEqual(str,RelativePath.Parse(str, typeTable).Format(typeTable));
}

/// <summary>
/// parse deep path string containing alphanumeric chars (mixed), starting with alphabetical chars.
/// </summary>
[Test]
public void RelativePathParseAlphanumericStringPath2()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/AA123A/bb78B9";
Assert.AreEqual(str, RelativePath.Parse(str, typeTable).Format(typeTable));
}

/// <summary>
/// parse deep path string containing only alphabetical chars.
/// </summary>
[Test]
public void RelativePathParseAlphaStringPath()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/abc/def";
Assert.AreEqual(str, RelativePath.Parse(str, typeTable).Format(typeTable));
}

/// <summary>
/// parse deep path string containing only alphabetical chars with namespace index
/// </summary>
[Test]
public void RelativePathParseAlphanumericWithNamespaceIndexStringPath()
{
TypeTable typeTable = new TypeTable(new NamespaceTable());
string str = "/1:abc/2:def";
Assert.AreEqual(str, RelativePath.Parse(str, typeTable).Format(typeTable));
}

#endregion
}

Expand Down

0 comments on commit d9498f5

Please sign in to comment.