diff options
Diffstat (limited to 'tests/format.test')
-rw-r--r-- | tests/format.test | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/format.test b/tests/format.test index f99861d..321f52f 100644 --- a/tests/format.test +++ b/tests/format.test @@ -10,24 +10,26 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: format.test,v 1.23 2005/10/13 21:49:46 dkf Exp $ +# RCS: @(#) $Id: format.test,v 1.24 2006/03/21 11:12:29 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 namespace import -force ::tcltest::* } +# %u output depends on word length, so this test is not portable. +testConstraint longIs32bit [expr {int(0x80000000) < 0}] +testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] +testConstraint wideIs64bit \ + [expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}] +testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}] + test format-1.1 {integer formatting} { format "%*d %d %d %d" 6 34 16923 -12 -1 } { 34 16923 -12 -1} test format-1.2 {integer formatting} { format "%4d %4d %4d %4d %d %#x %#X" 6 34 16923 -12 -1 14 12 } { 6 34 16923 -12 -1 0xe 0XC} - -# %u output depends on word length, so this test is not portable. -testConstraint longIs32bit [expr {int(0x80000000) < 0}] -testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] - test format-1.3 {integer formatting} longIs32bit { format "%4u %4u %4u %4u %d %#o" 6 34 16923 -12 -1 0 } { 6 34 16923 4294967284 -1 0} @@ -43,10 +45,8 @@ test format-1.5 {integer formatting} { test format-1.6 {integer formatting} { format "%00*d" 6 34 } {000034} - # Printing negative numbers in hex or octal format depends on word # length, so these tests are not portable. - test format-1.7 {integer formatting} longIs32bit { format "%4x %4x %4x %4x" 6 34 16923 -12 -1 } { 6 22 421b fffffff4} @@ -426,6 +426,7 @@ test format-11.12 {XPG3 %$n specifiers} { test format-12.1 {negative width specifiers} { format "%*d" -47 25 } {25 } + test format-13.1 {tcl_precision fuzzy comparison} { catch {unset a} catch {unset b} @@ -475,6 +476,7 @@ test format-13.5 {tcl_precision fuzzy comparison} { set c [expr $a + $b] format {%0.10f %0.12f %0.15f} $c $c $c } {1.4444444444 1.444444444444 1.444444444443990} + test format-14.1 {testing MAX_FLOAT_SIZE for 0 and 1} { format {%s} "" } {} @@ -502,16 +504,11 @@ for {set i 0} {$i < 290} {incr i} { } for {set i 290} {$i < 400} {incr i} { test format-16.[expr $i -289] {testing MAX_FLOAT_SIZE} { - format {%s} $b + format {%s} $b } $b append b "x" } -::tcltest::testConstraint wideIs64bit \ - [expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}] -::tcltest::testConstraint wideBiggerThanInt \ - [expr {wide(0x80000000) != int(0x80000000)}] - test format-17.1 {testing %d with wide} {wideIs64bit wideBiggerThanInt} { format %d 7810179016327718216 } 1819043144 @@ -563,3 +560,7 @@ catch {unset c} catch {unset d} ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: |