File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -95,9 +95,15 @@ fn from_str_radix(buf: str, radix: u64) -> option<u64> {
95
95
} ;
96
96
}
97
97
98
- #[ doc = "Convert to a string in a given base" ]
98
+ #[ doc = "
99
+ Convert to a string in a given base
100
+
101
+ # Failure
102
+
103
+ Fails if `radix` < 2 or `radix` > 16
104
+ " ]
99
105
fn to_str ( num : T , radix : uint ) -> str {
100
- assert ( 0 u < radix && radix <= 16 u) ;
106
+ assert ( 1 u < radix && radix <= 16 u) ;
101
107
let mut n = num;
102
108
let radix = radix as T ;
103
109
fn digit ( n : T ) -> u8 {
@@ -167,3 +173,17 @@ fn test_parse_buf() {
167
173
assert parse_buf( str:: bytes ( "Z" ) , 10 u) == none;
168
174
assert parse_buf( str:: bytes ( "_" ) , 2 u) == none;
169
175
}
176
+
177
+ #[ test]
178
+ #[ should_fail]
179
+ #[ ignore( cfg( target_os = "win32" ) ) ]
180
+ fn to_str_radix1 ( ) {
181
+ uint:: to_str ( 100 u, 1 u) ;
182
+ }
183
+
184
+ #[ test]
185
+ #[ should_fail]
186
+ #[ ignore( cfg( target_os = "win32" ) ) ]
187
+ fn to_str_radix17 ( ) {
188
+ uint:: to_str ( 100 u, 17 u) ;
189
+ }
You can’t perform that action at this time.
0 commit comments