about summary refs log tree commit diff
path: root/src/libcore/uint-template.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/uint-template.rs')
-rw-r--r--src/libcore/uint-template.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 0904a6d9382..6e513b2f5e2 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -95,9 +95,15 @@ fn from_str_radix(buf: str, radix: u64) -> option<u64> {
     };
 }
 
-#[doc = "Convert to a string in a given base"]
+#[doc = "
+Convert to a string in a given base
+
+# Failure
+
+Fails if `radix` < 2 or `radix` > 16
+"]
 fn to_str(num: T, radix: uint) -> str {
-    assert (0u < radix && radix <= 16u);
+    assert (1u < radix && radix <= 16u);
     let mut n = num;
     let radix = radix as T;
     fn digit(n: T) -> u8 {
@@ -167,3 +173,17 @@ fn test_parse_buf() {
     assert parse_buf(str::bytes("Z"), 10u) == none;
     assert parse_buf(str::bytes("_"), 2u) == none;
 }
+
+#[test]
+#[should_fail]
+#[ignore(cfg(target_os = "win32"))]
+fn to_str_radix1() {
+    uint::to_str(100u, 1u);
+}
+
+#[test]
+#[should_fail]
+#[ignore(cfg(target_os = "win32"))]
+fn to_str_radix17() {
+    uint::to_str(100u, 17u);
+}