Fix positive `PyInt` converted to negative `BigInteger` by lostmsu · Pull Request #1993 · pythonnet/pythonnet · GitHub
Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
17 changes: 12 additions & 5 deletions src/embed_tests/TestPyInt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,23 @@ public void ToBigInteger()
{
0, 1, 2,
0x10,
0x79,
0x80,
0x81,
0xFF,
0x123,
0x8000,
0x1234,
0x8001,
0x4000,
0xFF,
};
simpleValues = simpleValues.Concat(simpleValues.Select(v => -v)).ToArray();

foreach (var val in simpleValues)
{
var pyInt = new PyInt(val);
Assert.AreEqual((BigInteger)val, pyInt.ToBigInteger());
}
var expected = simpleValues.Select(v => new BigInteger(v)).ToArray();
var actual = simpleValues.Select(v => new PyInt(v).ToBigInteger()).ToArray();

CollectionAssert.AreEqual(expected, actual);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/PythonTypes/PyInt.cs