xref: /PHP-7.2/ext/gmp/tests/bug50283.phpt (revision bb0c1421)
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--FILE--
6<?php
7$a = gmp_init("0x41682179fbf5");
8printf("Decimal: %s, -36-based: %s\n", gmp_strval($a), gmp_strval($a,-36));
9printf("Decimal: %s, 36-based: %s\n", gmp_strval($a), gmp_strval($a,36));
10printf("Decimal: %s, -1-based: %s\n", gmp_strval($a), gmp_strval($a,-1));
11printf("Decimal: %s, 1-based: %s\n", gmp_strval($a), gmp_strval($a,1));
12printf("Decimal: %s, -37-based: %s\n", gmp_strval($a), gmp_strval($a,-37));
13printf("Decimal: %s, 37-based: %s\n", gmp_strval($a), gmp_strval($a,37));
14printf("Decimal: %s, 62-based: %s\n", gmp_strval($a), gmp_strval($a,62));
15printf("Decimal: %s, 63-based: %s\n\n", gmp_strval($a), gmp_strval($a,63));
16printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62));
17?>
18--EXPECTF--
19Decimal: 71915494046709, -36-based: PHPISCOOL
20Decimal: 71915494046709, 36-based: phpiscool
21
22Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line 5
23Decimal: 71915494046709, -1-based:
24
25Warning: gmp_strval(): Bad base for conversion: 1 (should be between 2 and %d or -2 and -%d) in %s on line 6
26Decimal: 71915494046709, 1-based:
27
28Warning: gmp_strval(): Bad base for conversion: -37 (should be between 2 and %d or -2 and -%d) in %s on line 7
29Decimal: 71915494046709, -37-based:
30Decimal: 71915494046709, 37-based: KHKATELJF
31Decimal: 71915494046709, 62-based: KQ6yq741
32
33Warning: gmp_strval(): Bad base for conversion: 63 (should be between 2 and %d or -2 and -%d) in %s on line 10
34Decimal: 71915494046709, 63-based:
35
36Base 32 and 62-based: 1NHkAcdIiD
37