comparison tests/automated/lisp-tests.el @ 448:3078fd1074e8 r21-2-39

Import from CVS: tag r21-2-39
author cvs
date Mon, 13 Aug 2007 11:38:25 +0200
parents 1ccc32a20af4
children 5aa1854ad537
comparison
equal deleted inserted replaced
447:4fc5f13f3bd3 448:3078fd1074e8
996 (Assert (string= (format "%x" 31) "1f")) 996 (Assert (string= (format "%x" 31) "1f"))
997 (Assert (string= (format "%X" 31) "1F")) 997 (Assert (string= (format "%X" 31) "1F"))
998 (Assert (string= (format "%e" 100) "1.000000e+02")) 998 (Assert (string= (format "%e" 100) "1.000000e+02"))
999 (Assert (string= (format "%E" 100) "1.000000E+02")) 999 (Assert (string= (format "%E" 100) "1.000000E+02"))
1000 (Assert (string= (format "%f" 100) "100.000000")) 1000 (Assert (string= (format "%f" 100) "100.000000"))
1001 (Assert (string= (format "%7.3f" 12.12345) " 12.123"))
1002 (Assert (string= (format "%07.3f" 12.12345) "012.123"))
1003 (Assert (string= (format "%-7.3f" 12.12345) "12.123 "))
1004 (Assert (string= (format "%-07.3f" 12.12345) "12.123 "))
1001 (Assert (string= (format "%g" 100.0) "100")) 1005 (Assert (string= (format "%g" 100.0) "100"))
1002 (Assert (string= (format "%g" 0.000001) "1e-06")) 1006 (Assert (string= (format "%g" 0.000001) "1e-06"))
1003 (Assert (string= (format "%g" 0.0001) "0.0001")) 1007 (Assert (string= (format "%g" 0.0001) "0.0001"))
1004 (Assert (string= (format "%G" 100.0) "100")) 1008 (Assert (string= (format "%G" 100.0) "100"))
1005 (Assert (string= (format "%G" 0.000001) "1E-06")) 1009 (Assert (string= (format "%G" 0.000001) "1E-06"))
1037 (Assert (string= (format "%#G" 0.000001) "1.00000E-06")) 1041 (Assert (string= (format "%#G" 0.000001) "1.00000E-06"))
1038 (Assert (string= (format "%#G" 0.0001) "0.000100000")) 1042 (Assert (string= (format "%#G" 0.0001) "0.000100000"))
1039 (Assert (string= (format "%.1d" 10) "10")) 1043 (Assert (string= (format "%.1d" 10) "10"))
1040 (Assert (string= (format "%.4d" 10) "0010")) 1044 (Assert (string= (format "%.4d" 10) "0010"))
1041 ;; Combination of `-', `+', ` ', `0', `#', `.', `*' 1045 ;; Combination of `-', `+', ` ', `0', `#', `.', `*'
1042 (Assert (string= (format "%-04d" 10) "0010")) 1046 (Assert (string= (format "%-04d" 10) "10 "))
1043 (Assert (string= (format "%-*d" 4 10) "10 ")) 1047 (Assert (string= (format "%-*d" 4 10) "10 "))
1044 ;; #### Correctness of this behavior is questionable. 1048 ;; #### Correctness of this behavior is questionable.
1045 ;; It might be better to signal error. 1049 ;; It might be better to signal error.
1046 (Assert (string= (format "%-*d" -4 10) "10 ")) 1050 (Assert (string= (format "%-*d" -4 10) "10 "))
1047 ;; These behavior is not specified. 1051 ;; These behavior is not specified.
1050 ;; (format "%-01d" 10) 1054 ;; (format "%-01d" 10)
1051 ;; (format "%-#4x" 10) 1055 ;; (format "%-#4x" 10)
1052 ;; (format "%-.1d" 10) 1056 ;; (format "%-.1d" 10)
1053 1057
1054 (Assert (string= (format "%01.1d" 10) "10")) 1058 (Assert (string= (format "%01.1d" 10) "10"))
1055 (Assert (string= (format "%03.1d" 10) "010")) 1059 (Assert (string= (format "%03.1d" 10) " 10"))
1056 (Assert (string= (format "%01.3d" 10) "10")) 1060 (Assert (string= (format "%01.3d" 10) "010"))
1057 (Assert (string= (format "%1.3d" 10) "10")) 1061 (Assert (string= (format "%1.3d" 10) "010"))
1058 (Assert (string= (format "%3.1d" 10) " 10")) 1062 (Assert (string= (format "%3.1d" 10) " 10"))
1063
1064 ;;; The following two tests used to use 1000 instead of 100,
1065 ;;; but that merely found buffer overflow bugs in Solaris sprintf().
1066 (Assert (= 102 (length (format "%.100f" 3.14))))
1067 (Assert (= 100 (length (format "%100f" 3.14))))
1059 1068
1060 ;;; Check for 64-bit cleanness on LP64 platforms. 1069 ;;; Check for 64-bit cleanness on LP64 platforms.
1061 (Assert (= (read (format "%d" most-positive-fixnum)) most-positive-fixnum)) 1070 (Assert (= (read (format "%d" most-positive-fixnum)) most-positive-fixnum))
1062 (Assert (= (read (format "%ld" most-positive-fixnum)) most-positive-fixnum)) 1071 (Assert (= (read (format "%ld" most-positive-fixnum)) most-positive-fixnum))
1063 (Assert (= (read (format "%u" most-positive-fixnum)) most-positive-fixnum)) 1072 (Assert (= (read (format "%u" most-positive-fixnum)) most-positive-fixnum))
1069 ;;; What to do if "%u" is used with a negative number? 1078 ;;; What to do if "%u" is used with a negative number?
1070 ;;; The most reasonable thing seems to be to print an un-read-able number. 1079 ;;; The most reasonable thing seems to be to print an un-read-able number.
1071 ;;; The printed value might be useful to a human, if not to Emacs Lisp. 1080 ;;; The printed value might be useful to a human, if not to Emacs Lisp.
1072 (Check-Error invalid-read-syntax (read (format "%u" most-negative-fixnum))) 1081 (Check-Error invalid-read-syntax (read (format "%u" most-negative-fixnum)))
1073 (Check-Error invalid-read-syntax (read (format "%u" -1))) 1082 (Check-Error invalid-read-syntax (read (format "%u" -1)))
1083
1084 ;; Check all-completions ignore element start with space.
1085 (Assert (not (all-completions "" '((" hidden" . "object")))))
1086 (Assert (all-completions " " '((" hidden" . "object"))))