diff options
| author | Paul Eggert | 2017-12-07 18:07:54 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-12-07 18:08:56 -0800 |
| commit | 47423f0603f2ecfb78352be5477fb02c44f1fd35 (patch) | |
| tree | 78c40843566e2464c5d84dd12d4057d064b768e3 /test/src | |
| parent | d4db37b283daffa0f8c942a5b526b6444edc34c5 (diff) | |
| download | emacs-47423f0603f2ecfb78352be5477fb02c44f1fd35.tar.gz emacs-47423f0603f2ecfb78352be5477fb02c44f1fd35.zip | |
Fix zero-padding bug with (format "%#08x" n)
Problem reported by Gustaf Waldemarson (Bug#29609).
* src/editfns.c (styled_format):
Put zero padding after a leading "0x", not before.
* test/src/editfns-tests.el (format-sharp-0-x): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/editfns-tests.el | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 70dc9372fad..283a642dd97 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -136,6 +136,12 @@ | |||
| 136 | (ert-deftest format-c-float () | 136 | (ert-deftest format-c-float () |
| 137 | (should-error (format "%c" 0.5))) | 137 | (should-error (format "%c" 0.5))) |
| 138 | 138 | ||
| 139 | ;;; Test for Bug#29609. | ||
| 140 | (ert-deftest format-sharp-0-x () | ||
| 141 | (should (string-equal (format "%#08x" #x10) "0x000010")) | ||
| 142 | (should (string-equal (format "%#05X" #x10) "0X010")) | ||
| 143 | (should (string-equal (format "%#04x" 0) "0000"))) | ||
| 144 | |||
| 139 | ;;; Check format-time-string with various TZ settings. | 145 | ;;; Check format-time-string with various TZ settings. |
| 140 | ;;; Use only POSIX-compatible TZ values, since the tests should work | 146 | ;;; Use only POSIX-compatible TZ values, since the tests should work |
| 141 | ;;; even if tzdb is not in use. | 147 | ;;; even if tzdb is not in use. |