Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/rx/observables/StringObservable.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -420,14 +420,16 @@ public Subscriber<? super String> call(final Subscriber<? super String> o){

@Override
public void onCompleted(){
output(leftOver);
if (leftOver!=null)
output(leftOver);
if (!o.isUnsubscribed())
o.onCompleted();
}

@Override
public void onError(Throwable e){
output(leftOver);
if (leftOver!=null)
output(leftOver);
if (!o.isUnsubscribed())
o.onError(e);
}
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/rx/observables/StringObservableTest.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,6 +142,24 @@ public void testSplitOnOh(){
testSplit("boo:and:foo", "o", 0, "b", "", ":and:f");
}

@Test
public void testSplitOnEmptyStream(){
assertEquals(0, (int) StringObservable.split(Observable.<String>empty(), "\n")
.count().toBlocking().single());
}

@Test
public void testSplitOnStreamThatThrowsExceptionImmediately(){
RuntimeException ex = new RuntimeException("boo");
try{
StringObservable.split(Observable.<String>error(ex), "\n")
.count().toBlocking().single();
fail();
} catch (RuntimeException e){
assertEquals(ex, e);
}
}

public void testSplit(String str, String regex, int limit, String... parts){
testSplit(str, regex, 0, Observable.just(str), parts);
for (int i = 0; i < str.length(); i++){
Expand Down