@@ -1434,7 +1434,7 @@ public void withTag() {
14341434 .assertResult (1 )
14351435 ;
14361436 }
1437- fail ("Should have thrown!" );
1437+ throw new RuntimeException ("Should have thrown!" );
14381438 } catch (AssertionError ex ) {
14391439 assertTrue (ex .toString (), ex .toString ().contains ("testing with item=2" ));
14401440 }
@@ -1466,7 +1466,7 @@ public void assertValuesOnlyThrowsOnUnexpectedValue() {
14661466
14671467 try {
14681468 to .assertValuesOnly (5 );
1469- fail ();
1469+ throw new RuntimeException ();
14701470 } catch (AssertionError ex ) {
14711471 // expected
14721472 }
@@ -1481,7 +1481,7 @@ public void assertValuesOnlyThrowsWhenCompleted() {
14811481
14821482 try {
14831483 to .assertValuesOnly ();
1484- fail ();
1484+ throw new RuntimeException ();
14851485 } catch (AssertionError ex ) {
14861486 // expected
14871487 }
@@ -1496,7 +1496,131 @@ public void assertValuesOnlyThrowsWhenErrored() {
14961496
14971497 try {
14981498 to .assertValuesOnly ();
1499- fail ();
1499+ throw new RuntimeException ();
1500+ } catch (AssertionError ex ) {
1501+ // expected
1502+ }
1503+ }
1504+
1505+ @ Test
1506+ public void assertValueSetOnly () {
1507+ TestObserver <Integer > to = TestObserver .create ();
1508+ to .onSubscribe (Disposables .empty ());
1509+ to .assertValueSetOnly (Collections .<Integer >emptySet ());
1510+
1511+ to .onNext (5 );
1512+ to .assertValueSetOnly (Collections .singleton (5 ));
1513+
1514+ to .onNext (-1 );
1515+ to .assertValueSetOnly (new HashSet <Integer >(Arrays .asList (5 , -1 )));
1516+ }
1517+
1518+ @ Test
1519+ public void assertValueSetOnlyThrowsOnUnexpectedValue () {
1520+ TestObserver <Integer > to = TestObserver .create ();
1521+ to .onSubscribe (Disposables .empty ());
1522+ to .assertValueSetOnly (Collections .<Integer >emptySet ());
1523+
1524+ to .onNext (5 );
1525+ to .assertValueSetOnly (Collections .singleton (5 ));
1526+
1527+ to .onNext (-1 );
1528+
1529+ try {
1530+ to .assertValueSetOnly (Collections .singleton (5 ));
1531+ throw new RuntimeException ();
1532+ } catch (AssertionError ex ) {
1533+ // expected
1534+ }
1535+ }
1536+
1537+ @ Test
1538+ public void assertValueSetOnlyThrowsWhenCompleted () {
1539+ TestObserver <Integer > to = TestObserver .create ();
1540+ to .onSubscribe (Disposables .empty ());
1541+
1542+ to .onComplete ();
1543+
1544+ try {
1545+ to .assertValueSetOnly (Collections .<Integer >emptySet ());
1546+ throw new RuntimeException ();
1547+ } catch (AssertionError ex ) {
1548+ // expected
1549+ }
1550+ }
1551+
1552+ @ Test
1553+ public void assertValueSetOnlyThrowsWhenErrored () {
1554+ TestObserver <Integer > to = TestObserver .create ();
1555+ to .onSubscribe (Disposables .empty ());
1556+
1557+ to .onError (new TestException ());
1558+
1559+ try {
1560+ to .assertValueSetOnly (Collections .<Integer >emptySet ());
1561+ throw new RuntimeException ();
1562+ } catch (AssertionError ex ) {
1563+ // expected
1564+ }
1565+ }
1566+
1567+ @ Test
1568+ public void assertValueSequenceOnly () {
1569+ TestObserver <Integer > to = TestObserver .create ();
1570+ to .onSubscribe (Disposables .empty ());
1571+ to .assertValueSequenceOnly (Collections .<Integer >emptyList ());
1572+
1573+ to .onNext (5 );
1574+ to .assertValueSequenceOnly (Collections .singletonList (5 ));
1575+
1576+ to .onNext (-1 );
1577+ to .assertValueSequenceOnly (Arrays .asList (5 , -1 ));
1578+ }
1579+
1580+ @ Test
1581+ public void assertValueSequenceOnlyThrowsOnUnexpectedValue () {
1582+ TestObserver <Integer > to = TestObserver .create ();
1583+ to .onSubscribe (Disposables .empty ());
1584+ to .assertValueSequenceOnly (Collections .<Integer >emptyList ());
1585+
1586+ to .onNext (5 );
1587+ to .assertValueSequenceOnly (Collections .singletonList (5 ));
1588+
1589+ to .onNext (-1 );
1590+
1591+ try {
1592+ to .assertValueSequenceOnly (Collections .singletonList (5 ));
1593+ throw new RuntimeException ();
1594+ } catch (AssertionError ex ) {
1595+ // expected
1596+ }
1597+ }
1598+
1599+ @ Test
1600+ public void assertValueSequenceOnlyThrowsWhenCompleted () {
1601+ TestObserver <Integer > to = TestObserver .create ();
1602+ to .onSubscribe (Disposables .empty ());
1603+
1604+ to .onComplete ();
1605+
1606+ try {
1607+ to .assertValueSequenceOnly (Collections .<Integer >emptyList ());
1608+ throw new RuntimeException ();
1609+ } catch (AssertionError ex ) {
1610+ // expected
1611+ }
1612+ }
1613+
1614+ @ Test
1615+ public void assertValueSequenceOnlyThrowsWhenErrored () {
1616+ TestObserver <Integer > to = TestObserver .create ();
1617+ to .onSubscribe (Disposables .empty ());
1618+
1619+ to .onError (new TestException ());
1620+
1621+ try {
1622+ to .assertValueSequenceOnly (Collections .<Integer >emptyList ());
1623+ throw new RuntimeException ();
15001624 } catch (AssertionError ex ) {
15011625 // expected
15021626 }
0 commit comments