aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-04-17 17:06:55 -0400
committerBrian Anderson <[email protected]>2011-04-17 17:06:55 -0400
commit685e82046539b9e06c3ef6d6269285fdcbe8e1f0 (patch)
tree3d60970ae80930caf377e556554bc7d61ae8b2b1
parentSupport #fmt precision for signed types (diff)
downloadrust-685e82046539b9e06c3ef6d6269285fdcbe8e1f0.tar.xz
rust-685e82046539b9e06c3ef6d6269285fdcbe8e1f0.zip
Treat char #fmt conversions just like str conversions
Add missing tests
-rw-r--r--src/lib/ExtFmt.rs2
-rw-r--r--src/test/run-pass/syntax-extension-fmt.rs6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs
index 23290384..bbcb14bd 100644
--- a/src/lib/ExtFmt.rs
+++ b/src/lib/ExtFmt.rs
@@ -366,7 +366,7 @@ mod RT {
}
fn conv_char(&conv cv, char c) -> str {
- ret pad(cv, _str.from_char(c));
+ ret conv_str(cv, _str.from_char(c));
}
fn conv_str(&conv cv, str s) -> str {
diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs
index b75529fa..e229fce5 100644
--- a/src/test/run-pass/syntax-extension-fmt.rs
+++ b/src/test/run-pass/syntax-extension-fmt.rs
@@ -43,6 +43,7 @@ fn main() {
test(#fmt("%10x", 0xff_u), " ff");
test(#fmt("%10X", 0xff_u), " FF");
test(#fmt("%10t", 0xff_u), " 11111111");
+ test(#fmt("%10c", 'A'), " A");
// Left justify
test(#fmt("%-10d", 500), "500 ");
@@ -53,6 +54,7 @@ fn main() {
test(#fmt("%-10x", 0xff_u), "ff ");
test(#fmt("%-10X", 0xff_u), "FF ");
test(#fmt("%-10t", 0xff_u), "11111111 ");
+ test(#fmt("%-10c", 'A'), "A ");
// Precision
test(#fmt("%.d", 0), "");
@@ -65,6 +67,7 @@ fn main() {
test(#fmt("%.s", "test"), "");
test(#fmt("%.x", 127u), "7f");
test(#fmt("%.t", 3u), "11");
+ test(#fmt("%.c", 'A'), "");
test(#fmt("%.0d", 0), "");
test(#fmt("%.0u", 0u), "");
@@ -76,6 +79,7 @@ fn main() {
test(#fmt("%.0s", "test"), "");
test(#fmt("%.0x", 127u), "7f");
test(#fmt("%.0t", 3u), "11");
+ test(#fmt("%.0c", 'A'), "");
test(#fmt("%.1d", 0), "0");
test(#fmt("%.1u", 0u), "0");
@@ -87,6 +91,7 @@ fn main() {
test(#fmt("%.1s", "test"), "t");
test(#fmt("%.1x", 127u), "7f");
test(#fmt("%.1t", 3u), "11");
+ test(#fmt("%.1c", 'A'), "A");
test(#fmt("%.5d", 0), "00000");
test(#fmt("%.5u", 0u), "00000");
@@ -98,4 +103,5 @@ fn main() {
test(#fmt("%.5s", "test"), "test");
test(#fmt("%.5x", 127u), "0007f");
test(#fmt("%.5t", 3u), "00011");
+ test(#fmt("%.5c", 'A'), "A");
}