aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorPaul Eggert2018-08-31 00:25:07 -0700
committerPaul Eggert2018-08-31 00:28:58 -0700
commitdb2fed3bdfb351c3283e481829ce687931d27a3d (patch)
tree4f2674ec4f4fe450fd483132b9ddcca48f9eaf81 /test/src
parenta451c6ec12b7b024f347364becb10c49807513ed (diff)
downloademacs-db2fed3bdfb351c3283e481829ce687931d27a3d.tar.gz
emacs-db2fed3bdfb351c3283e481829ce687931d27a3d.zip
Several fixes for formatting bignums
* src/bignum.c: Include stdlib.h, for abs. (bignum_bufsize, bignum_to_c_string): New functions. * src/bignum.c (bignum_to_string): * src/print.c (print_vectorlike): Use them. * src/editfns.c (styled_format): Instead of having a separate buffer for sprintf (which does not work for bignums), just append to the main buffer. When formatting bignums, add support for the standard integer flags -, #, 0, + and space. Fix some comments. Capitalize properly when formatting bignums with %X. Use functions like c_isdigit rather than reinventing the wheel. Simplify computation of excess precision. * src/print.c: Do not include bignum.h; no longer needed. (print_vectorlike): Avoid recalculating string length. * test/src/editfns-tests.el (format-bignum): Test some of the above fixes.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/editfns-tests.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 964ff088360..487f3aaa666 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -381,10 +381,23 @@
381 (let* ((s1 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") 381 (let* ((s1 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
382 (v1 (read (concat "#x" s1))) 382 (v1 (read (concat "#x" s1)))
383 (s2 "99999999999999999999999999999999") 383 (s2 "99999999999999999999999999999999")
384 (v2 (read s2))) 384 (v2 (read s2))
385 (v3 #x-3ffffffffffffffe000000000000000))
385 (should (> v1 most-positive-fixnum)) 386 (should (> v1 most-positive-fixnum))
386 (should (equal (format "%X" v1) s1)) 387 (should (equal (format "%X" v1) s1))
387 (should (> v2 most-positive-fixnum)) 388 (should (> v2 most-positive-fixnum))
388 (should (equal (format "%d" v2) s2)))) 389 (should (equal (format "%d" v2) s2))
390 (should (equal (format "%d" v3) "-5316911983139663489309385231907684352"))
391 (should (equal (format "%+d" v3) "-5316911983139663489309385231907684352"))
392 (should (equal (format "%+d" (- v3))
393 "+5316911983139663489309385231907684352"))
394 (should (equal (format "% d" (- v3))
395 " 5316911983139663489309385231907684352"))
396 (should (equal (format "%o" v3)
397 "-37777777777777777777600000000000000000000"))
398 (should (equal (format "%#50.40x" v3)
399 " -0x000000003ffffffffffffffe000000000000000"))
400 (should (equal (format "%-#50.40x" v3)
401 "-0x000000003ffffffffffffffe000000000000000 "))))
389 402
390;;; editfns-tests.el ends here 403;;; editfns-tests.el ends here