PageRenderTime 122ms CodeModel.GetById 81ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 39 lines | 25 code | 6 blank | 8 comment | 0 complexity | f9c9528673161975c9b41f61f35feb59 MD5 | raw file
 1/**
 2 * BigIntegerTest
 3 * 
 4 * A test class for BigInteger
 5 * Copyright (c) 2007 Henri Torgemane
 6 * 
 7 * See LICENSE.txt for full license information.
 8 */
 9package com.hurlant.crypto.tests
10{
11	import com.hurlant.math.BigInteger;
12	import com.hurlant.util.Hex;
13	
14	public class BigIntegerTest extends TestCase
15	{
16		public function BigIntegerTest(h:ITestHarness)
17		{
18			super(h, "BigInteger Tests");
19			runTest(testAdd, "BigInteger Addition");
20			h.endTestCase();
21		}
22		
23		public function testAdd():void {
24			var n1:BigInteger = BigInteger.nbv(25);
25			var n2:BigInteger = BigInteger.nbv(1002);
26			var n3:BigInteger = n1.add(n2);
27			var v:int = n3.valueOf();
28			assert("25+1002 = "+v, 25+1002==v);
29
30			var p:BigInteger = new BigInteger(Hex.toArray("e564d8b801a61f47"));
31			var xp:BigInteger = new BigInteger(Hex.toArray("99246db2a3507fa"));
32			
33			xp = xp.add(p);
34			
35			assert("xp==eef71f932bdb2741", xp.toString(16)=="eef71f932bdb2741");
36		}
37		
38	}
39}