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;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BString(String text) {
|
||||||
|
this.bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
@Override()
|
@Override()
|
||||||
public boolean compare(BValue other) {
|
public boolean compare(BValue other) {
|
||||||
return Arrays.equals(((BString)other).get(), get());
|
return Arrays.equals(((BString)other).get(), get());
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,10 @@ public class EqualsTest {
|
||||||
assertEquals(new BInteger(1), new BInteger(1));
|
assertEquals(new BInteger(1), new BInteger(1));
|
||||||
assertNotEquals(new BInteger(2), new BInteger(3));
|
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