Skip to content

Commit 07ff1d8

Browse files
committed
---
yaml --- r: 11257 b: refs/heads/master c: 6983464 h: refs/heads/master i: 11255: 24a28aa v: v3
1 parent 82db560 commit 07ff1d8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2600db4778dac418309320bed235a1025d84c630
2+
refs/heads/master: 69834646d2efd2170236b1f8db3a71c77e378c5b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ fn find(haystack: str, needle: str) -> option<uint> {
920920
// Convert a byte position into a char position
921921
// within a given string
922922
fn b2c_pos(ss: str, bpos: uint) -> uint {
923-
assert bpos < len_bytes(ss);
923+
assert bpos == 0u || bpos < len_bytes(ss);
924924

925925
let ii = 0u;
926926
let cpos = 0u;
@@ -1725,6 +1725,9 @@ mod tests {
17251725
#[test]
17261726
fn test_find_bytes() {
17271727
// byte positions
1728+
assert (find_bytes("banana", "apple pie") == option::none);
1729+
assert (find_bytes("", "") == option::some(0u));
1730+
17281731
let data = "ประเทศไทย中华Việt Nam";
17291732
assert (find_bytes(data, "") == option::some(0u));
17301733
assert (find_bytes(data, "ประเ") == option::some( 0u));
@@ -1736,6 +1739,9 @@ mod tests {
17361739
#[test]
17371740
fn test_find() {
17381741
// char positions
1742+
assert (find("banana", "apple pie") == option::none);
1743+
assert (find("", "") == option::some(0u));
1744+
17391745
let data = "ประเทศไทย中华Việt Nam";
17401746
assert (find(data, "") == option::some(0u));
17411747
assert (find(data, "ประเ") == option::some(0u));

0 commit comments

Comments
 (0)