about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2013-08-24 12:09:18 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2013-08-24 12:12:30 +0200
commitcc477dfa74b78511f96cae5b8b39c3ea391d3779 (patch)
treed8b1c1904250cd07ab542e190af7552894200f51 /src/libextra
parentae63a3e400970a895d03ec1ef359ba86217c854b (diff)
downloadrust-cc477dfa74b78511f96cae5b8b39c3ea391d3779.tar.gz
rust-cc477dfa74b78511f96cae5b8b39c3ea391d3779.zip
Added note that there is still more to do on 5516.
Also added regression test for the byte vs codepoint issues that the
previous commit fixes.
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/getopts.rs33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs
index f5efa940530..87aab3fbae2 100644
--- a/src/libextra/getopts.rs
+++ b/src/libextra/getopts.rs
@@ -690,7 +690,7 @@ pub mod groups {
                 }
             }
 
-            // FIXME: #5516
+            // FIXME: #5516 should be graphemes not codepoints
             // here we just need to indent the start of the description
             let rowlen = str::count_chars(row, 0, row.len());
             if rowlen < 24 {
@@ -708,14 +708,14 @@ pub mod groups {
                 desc_normalized_whitespace.push_char(' ');
             }
 
-            // FIXME: #5516
+            // FIXME: #5516 should be graphemes not codepoints
             let mut desc_rows = ~[];
             do each_split_within(desc_normalized_whitespace, 54) |substr| {
                 desc_rows.push(substr.to_owned());
                 true
             };
 
-            // FIXME: #5516
+            // FIXME: #5516 should be graphemes not codepoints
             // wrapped description
             row.push_str(desc_rows.connect(desc_sep));
 
@@ -1581,4 +1581,31 @@ Options:
         debug!("generated: <<%s>>", usage);
         assert!(usage == expected)
     }
+
+    #[test]
+    fn test_groups_usage_description_multibyte_handling() {
+        let optgroups = ~[
+            groups::optflag("k", "k\u2013w\u2013",
+                "The word kiwi is normally spelled with two i's"),
+            groups::optflag("a", "apple",
+                "This \u201Cdescription\u201D has some characters that could \
+confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."),
+        ];
+
+        let expected =
+~"Usage: fruits
+
+Options:
+    -k --k–w–           The word kiwi is normally spelled with two i's
+    -a --apple          This “description” has some characters that could
+                        confuse the line wrapping; an apple costs 0.51€ in
+                        some parts of Europe.
+";
+
+        let usage = groups::usage("Usage: fruits", optgroups);
+
+        debug!("expected: <<%s>>", expected);
+        debug!("generated: <<%s>>", usage);
+        assert!(usage == expected)
+    }
 }