-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRStringTest.java
More file actions
37 lines (29 loc) · 1.18 KB
/
RStringTest.java
File metadata and controls
37 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.holi;
import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
/**
* Created by selonj on 16-9-5.
*/
public class RStringTest {
@Test public void toJavaString() throws Exception {
assertThat(RString.valueOf("foo").toString(), equalTo("foo"));
}
@Test public void equality() throws Exception {
assertThat(new RString("foo"), equalTo(new RString("foo")));
assertThat(new RString("foo"), not(equalTo(new RString(new StringBuilder("foo")))));
assertThat(new RString("foo"), not(equalTo(new RString("bar"))));
assertThat(new RString("foo"), not(equalTo("foo")));
assertThat(new RString("foo"), not(equalTo(null)));
}
@Test public void hash() throws Exception {
assertThat(RString.valueOf("foo").hashCode(), equalTo("foo".hashCode()));
}
@Test(expected = NullPointerException.class) public void throwsNullPointerExceptionIfCreateWithANullValue() throws Exception {
new RString(null);
}
@Test public void createRStringWithFactoryMethodCanAcceptANullValue() throws Exception {
assertThat(RString.valueOf(null), equalTo(new RString("null")));
}
}