PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms 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
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  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. */
  9. package com.hurlant.crypto.tests
  10. {
  11. import com.hurlant.math.BigInteger;
  12. import com.hurlant.util.Hex;
  13. public class BigIntegerTest extends TestCase
  14. {
  15. public function BigIntegerTest(h:ITestHarness)
  16. {
  17. super(h, "BigInteger Tests");
  18. runTest(testAdd, "BigInteger Addition");
  19. h.endTestCase();
  20. }
  21. public function testAdd():void {
  22. var n1:BigInteger = BigInteger.nbv(25);
  23. var n2:BigInteger = BigInteger.nbv(1002);
  24. var n3:BigInteger = n1.add(n2);
  25. var v:int = n3.valueOf();
  26. assert("25+1002 = "+v, 25+1002==v);
  27. var p:BigInteger = new BigInteger(Hex.toArray("e564d8b801a61f47"));
  28. var xp:BigInteger = new BigInteger(Hex.toArray("99246db2a3507fa"));
  29. xp = xp.add(p);
  30. assert("xp==eef71f932bdb2741", xp.toString(16)=="eef71f932bdb2741");
  31. }
  32. }
  33. }