1package org.mockito.internal.matchers; 2 3import org.junit.Test; 4 5import static org.junit.Assert.assertFalse; 6import static org.junit.Assert.assertTrue; 7 8/** 9 * Tests for the Matchers that operate over strings 10 */ 11public class StringMatchersTest { 12 @Test 13 public void startsWithString() { 14 assertTrue(new StartsWith("mockito").matches("mockito is here")); 15 } 16 17 @Test 18 public void doesNotStartWithString() { 19 assertFalse(new StartsWith("junit").matches("mockito is here")); 20 } 21 22 @Test 23 public void nullStartsWith() { 24 assertFalse(new StartsWith("java").matches(null)); 25 } 26 27 @Test 28 public void endsWithString() { 29 assertTrue(new EndsWith("mockito").matches("here is mockito")); 30 } 31 32 @Test 33 public void doesNotEndWithString() { 34 assertFalse(new EndsWith("junit").matches("here is mockito")); 35 } 36 37 @Test 38 public void nullEndsWith() { 39 assertFalse(new EndsWith("java").matches(null)); 40 } 41 42 @Test 43 public void containsString() { 44 assertTrue(new Contains("mockito").matches("****mockito****")); 45 } 46 47 @Test 48 public void stringDoesNotContain() { 49 assertFalse(new Contains("junit").matches("****mockito****")); 50 } 51 52 @Test 53 public void nullContainsNothing() { 54 assertFalse(new Contains("mockito").matches(null)); 55 } 56 57 @Test 58 public void matchesRegex() { 59 assertTrue(new Find("eleph.nt").matches("the elephant in the room")); 60 assertTrue(new Find("eleph.nt").matches("the elephInt in the room")); 61 } 62 63 @Test 64 public void doesNotMatchRegex() { 65 assertFalse(new Find("eleph.nt").matches("the otter in the room")); 66 } 67 68 @Test 69 public void nullDoesNotMatchRegex() { 70 assertFalse(new Find("eleph.nt").matches(null)); 71 } 72 73} 74