xref: /PHP-5.4/ext/gmp/tests/bug50283.phpt (revision b55d4ecb)
1--TEST--
2Feature Request #50283 (allow base in gmp_strval to use full range: 2 to 62, and -2 to -36)
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5<?php if (version_compare(GMP_VERSION, "4.2.0", "<")) print "skip"; ?>
6--FILE--
7<?php
8$a = gmp_init("0x41682179fbf5");
9printf("Decimal: %s, -36-based: %s\n", gmp_strval($a), gmp_strval($a,-36));
10printf("Decimal: %s, 36-based: %s\n", gmp_strval($a), gmp_strval($a,36));
11printf("Decimal: %s, -1-based: %s\n", gmp_strval($a), gmp_strval($a,-1));
12printf("Decimal: %s, 1-based: %s\n", gmp_strval($a), gmp_strval($a,1));
13printf("Decimal: %s, -37-based: %s\n", gmp_strval($a), gmp_strval($a,-37));
14printf("Decimal: %s, 37-based: %s\n", gmp_strval($a), gmp_strval($a,37));
15printf("Decimal: %s, 62-based: %s\n", gmp_strval($a), gmp_strval($a,62));
16printf("Decimal: %s, 63-based: %s\n\n", gmp_strval($a), gmp_strval($a,63));
17printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62));
18?>
19--EXPECTF--
20Decimal: 71915494046709, -36-based: PHPISCOOL
21Decimal: 71915494046709, 36-based: phpiscool
22
23Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line 5
24Decimal: 71915494046709, -1-based:
25
26Warning: gmp_strval(): Bad base for conversion: 1 (should be between 2 and %d or -2 and -%d) in %s on line 6
27Decimal: 71915494046709, 1-based:
28
29Warning: gmp_strval(): Bad base for conversion: -37 (should be between 2 and %d or -2 and -%d) in %s on line 7
30Decimal: 71915494046709, -37-based:
31Decimal: 71915494046709, 37-based: KHKATELJF
32Decimal: 71915494046709, 62-based: KQ6yq741
33
34Warning: gmp_strval(): Bad base for conversion: 63 (should be between 2 and %d or -2 and -%d) in %s on line 10
35Decimal: 71915494046709, 63-based:
36
37Base 32 and 62-based: 1NHkAcdIiD
38