diff --git a/build.vc11/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs b/build.vc11/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs index 0b882b87..b1b38358 100644 --- a/build.vc11/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs +++ b/build.vc11/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs @@ -35,6 +35,20 @@ namespace MPIR.Tests.HugeIntTests Assert.AreEqual("-222509832503450298345029835740293845720", b.ToString()); } } + + [TestMethod] + public void Swap() + { + using (var a = new HugeInt("-222509832503450298345029835740293845720")) + using (var b = new HugeInt("2039847290878794872059384789347534534")) + { + var aValue = a._value(); + var bValue = b._value(); + a.Swap(b); + Assert.AreEqual(bValue, a._value()); + Assert.AreEqual(aValue, b._value()); + } + } //more tests coming here } } diff --git a/build.vc11/mpir.net/mpir.net/HugeInt.h b/build.vc11/mpir.net/mpir.net/HugeInt.h index 0edea396..601e807d 100644 --- a/build.vc11/mpir.net/mpir.net/HugeInt.h +++ b/build.vc11/mpir.net/mpir.net/HugeInt.h @@ -367,5 +367,8 @@ namespace MPIR void SetTo(double value) { mpz_set_d(_value, value); } void SetTo(String^ value) { SetTo(value, 10); } void SetTo(String^ value, int base); + + //utility methods + void Swap(HugeInt^ a) { mpz_ptr temp = a->_value; a->_value = _value; _value = temp; } }; }; \ No newline at end of file