Skip to content

Commit

Permalink
Fix negative number compare bug
Browse files Browse the repository at this point in the history
- [Fixed] VersionEx.Parse could not handle negative number properly.
  • Loading branch information
ied206 committed Dec 30, 2017
1 parent b00d90c commit aec45a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions PEBakery.Tests/Core/Command/CommandBranchTests.cs
Expand Up @@ -349,6 +349,10 @@ public void Branch_IfEqual()
cond = new BranchCondition(type, false, "13", "0xC");
Assert.IsFalse(cond.Check(s, out d));

// Test for a bug reported in http://theoven.org/index.php?topic=2271.msg25381#msg25381
cond = new BranchCondition(type, false, "-1", "0");
Assert.IsFalse(cond.Check(s, out d));

BranchCondition_Comparison_Template(s, "A", "If,%Src%,Equal,A,Set,%Dest%,T", "T");
BranchCondition_Comparison_Template(s, "A", "If,%Src%,Equal,a,Set,%Dest%,T", "T");
BranchCondition_Comparison_Template(s, "10", "If,%Src%,Equal,09,Set,%Dest%,T", "F");
Expand Down
3 changes: 2 additions & 1 deletion PEBakery/Helper.cs
Expand Up @@ -1164,7 +1164,8 @@ public static VersionEx Parse(string str)
return null;
}

return new VersionEx(arr[0], arr[1], arr[2], arr[3]);
try { return new VersionEx(arr[0], arr[1], arr[2], arr[3]); }
catch { return null; }
}

public int CompareTo(VersionEx value)
Expand Down

0 comments on commit aec45a4

Please sign in to comment.