Joel Martin 0e486e1ba0 Import as3crypto_patch: ffda6e9cd8b1d74f45472c676afda8360ae1e5aa
as3crypto is actionscript 3 crypto library with TLS engine support.

From: http://github.com/lyokato/as3crypto_patched

Which was forked from: http://code.google.com/p/as3crypto/
2010-04-30 14:13:32 -05:00

39 lines
979 B
ActionScript
Executable File

/**
* BigIntegerTest
*
* A test class for BigInteger
* Copyright (c) 2007 Henri Torgemane
*
* See LICENSE.txt for full license information.
*/
package com.hurlant.crypto.tests
{
import com.hurlant.math.BigInteger;
import com.hurlant.util.Hex;
public class BigIntegerTest extends TestCase
{
public function BigIntegerTest(h:ITestHarness)
{
super(h, "BigInteger Tests");
runTest(testAdd, "BigInteger Addition");
h.endTestCase();
}
public function testAdd():void {
var n1:BigInteger = BigInteger.nbv(25);
var n2:BigInteger = BigInteger.nbv(1002);
var n3:BigInteger = n1.add(n2);
var v:int = n3.valueOf();
assert("25+1002 = "+v, 25+1002==v);
var p:BigInteger = new BigInteger(Hex.toArray("e564d8b801a61f47"));
var xp:BigInteger = new BigInteger(Hex.toArray("99246db2a3507fa"));
xp = xp.add(p);
assert("xp==eef71f932bdb2741", xp.toString(16)=="eef71f932bdb2741");
}
}
}