Skip to content

Commit 2c5ad5e

Browse files
committed
---
yaml --- r: 14263 b: refs/heads/try c: 6983464 h: refs/heads/master i: 14261: 32ce40a 14259: fe9175c 14255: 5ee4033 v: v3
1 parent ad6fa8d commit 2c5ad5e

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
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 2600db4778dac418309320bed235a1025d84c630
5+
refs/heads/try: 69834646d2efd2170236b1f8db3a71c77e378c5b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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)