make BString accept String
This commit is contained in:
parent
26901f81af
commit
94617078a4
2 changed files with 10 additions and 0 deletions
|
|
@ -10,6 +10,10 @@ public class BString extends BValue {
|
|||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public BString(String text) {
|
||||
this.bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override()
|
||||
public boolean compare(BValue other) {
|
||||
return Arrays.equals(((BString)other).get(), get());
|
||||
|
|
|
|||
|
|
@ -11,4 +11,10 @@ public class EqualsTest {
|
|||
assertEquals(new BInteger(1), new BInteger(1));
|
||||
assertNotEquals(new BInteger(2), new BInteger(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringEquals() {
|
||||
assertEquals(new BString("first"), new BString("first"));
|
||||
assertNotEquals(new BString("first"), new BString("second"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue