File: test_mpz_pack_unpack.txt

package info (click to toggle)
python-gmpy2 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,628 kB
  • ctags: 1,123
  • sloc: ansic: 21,036; python: 5,846; makefile: 163
file content (30 lines) | stat: -rw-r--r-- 846 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Testing of gmpy2 pack and unpack
--------------------------------

    >>> import gmpy2 as G
    >>> from gmpy2 import mpz,pack,unpack

Test
----

    >>> x = mpz(0)
    >>> all((x == pack(unpack(x,i),i) for i in range(1,100)))
    True
    >>> x = mpz(1)
    >>> all((x == pack(unpack(x,i),i) for i in range(1,100)))
    True
    >>> x = mpz(2)
    >>> all((x == pack(unpack(x,i),i) for i in range(1,100)))
    True
    >>> x = mpz(3141592635)
    >>> all((x == pack(unpack(x,i),i) for i in range(1,100)))
    True
    >>> x = mpz(1234567891234567890000000000000000000000000000000000000123)
    >>> all((x == pack(unpack(x,i),i) for i in range(1,100)))
    True
    >>> x = mpz(1) << 500
    >>> all((x == pack(unpack(x,i),i) for i in range(1,200)))
    True
    >>> x -= 1
    >>> all((x == pack(unpack(x,i),i) for i in range(1,200)))
    True