Skip to content

Commit ead4468

Browse files
committed
std: fix tests
1 parent ec5a028 commit ead4468

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/libstd/str.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,8 @@ pub fn with_capacity(capacity: uint) -> ~str {
11941194
* The number of Unicode characters in `s` between the given indices.
11951195
*/
11961196
pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
1197-
assert!(is_char_boundary(s, start));
1198-
assert!(is_char_boundary(s, end));
1197+
assert!(s.is_char_boundary(start));
1198+
assert!(s.is_char_boundary(end));
11991199
let mut (i, len) = (start, 0u);
12001200
while i < end {
12011201
let next = s.char_range_at(i).next;
@@ -1208,7 +1208,7 @@ pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
12081208
/// Counts the number of bytes taken by the first `n` chars in `s`
12091209
/// starting from `start`.
12101210
pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
1211-
assert!(is_char_boundary(s, start));
1211+
assert!(s.is_char_boundary(start));
12121212
let mut (end, cnt) = (start, n);
12131213
let l = s.len();
12141214
while cnt > 0u {
@@ -1658,7 +1658,7 @@ pub trait StrSlice<'self> {
16581658
fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str;
16591659
fn to_owned(&self) -> ~str;
16601660
fn to_managed(&self) -> @str;
1661-
fn is_char_boundary(s: &str, index: uint) -> bool;
1661+
fn is_char_boundary(&self, index: uint) -> bool;
16621662
fn char_range_at(&self, start: uint) -> CharRange;
16631663
fn char_at(&self, i: uint) -> char;
16641664
fn char_range_at_reverse(&self, start: uint) -> CharRange;
@@ -1800,8 +1800,8 @@ impl<'self> StrSlice<'self> for &'self str {
18001800
*/
18011801
#[inline]
18021802
fn slice(&self, begin: uint, end: uint) -> &'self str {
1803-
assert!(is_char_boundary(*self, begin));
1804-
assert!(is_char_boundary(*self, end));
1803+
assert!(self.is_char_boundary(begin));
1804+
assert!(self.is_char_boundary(end));
18051805
unsafe { raw::slice_bytes(*self, begin, end) }
18061806
}
18071807
#[inline]
@@ -2284,7 +2284,7 @@ impl<'self> Iterator<char> for StrCharIterator<'self> {
22842284
#[inline]
22852285
fn next(&mut self) -> Option<char> {
22862286
if self.index < self.string.len() {
2287-
let CharRange {ch, next} = char_range_at(self.string, self.index);
2287+
let CharRange {ch, next} = self.string.char_range_at(self.index);
22882288
self.index = next;
22892289
Some(ch)
22902290
} else {
@@ -2303,7 +2303,7 @@ impl<'self> Iterator<char> for StrCharRevIterator<'self> {
23032303
#[inline]
23042304
fn next(&mut self) -> Option<char> {
23052305
if self.index > 0 {
2306-
let CharRange {ch, next} = char_range_at_reverse(self.string, self.index);
2306+
let CharRange {ch, next} = self.string.char_range_at_reverse(self.index);
23072307
self.index = next;
23082308
Some(ch)
23092309
} else {
@@ -2461,7 +2461,7 @@ mod tests {
24612461
24622462
let data = "abcabc";
24632463
assert_eq!(data.slice(0u, 6u).find_str("ab"), Some(0u));
2464-
assert_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u));
2464+
assert_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u - 2u));
24652465
assert!(data.slice(2u, 4u).find_str("ab").is_none());
24662466
24672467
let mut data = ~"ประเทศไทย中华Việt Nam";
@@ -3042,10 +3042,10 @@ mod tests {
30423042
30433043
#[test]
30443044
fn test_contains_char() {
3045-
assert!(contains_char("abc", 'b'));
3046-
assert!(contains_char("a", 'a'));
3047-
assert!(!contains_char("abc", 'd'));
3048-
assert!(!contains_char("", 'a'));
3045+
assert!("abc".contains_char('b'));
3046+
assert!("a".contains_char('a'));
3047+
assert!(!"abc".contains_char('d'));
3048+
assert!(!"".contains_char('a'));
30493049
}
30503050
30513051
#[test]

0 commit comments

Comments
 (0)