use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class AsciiStringTest method testHashcode.
public void testHashcode() {
AsciiString str = new AsciiString("hello"), str2 = new AsciiString("hello");
assert str.hashCode() == str2.hashCode();
str2 = new AsciiString("hello world");
assert str.hashCode() != str2.hashCode();
Map<AsciiString, Integer> map = new HashMap<>(5);
map.put(new AsciiString("a"), 1);
assert map.get(new AsciiString("a")) == 1;
map.put(new AsciiString("b"), 2);
assert map.get(new AsciiString("b")) == 2;
map.put(new AsciiString("a"), 2);
assert map.get(new AsciiString("a")) == 2;
}
use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class BitsTest method testAsciiString.
public void testAsciiString() throws Exception {
AsciiString[] strings = { null, new AsciiString("hello world"), new AsciiString("1") };
for (AsciiString str : strings) {
byte[] buf = marshall(str);
AsciiString s = unmarshallAsciiString(buf);
assert str == null && s == null || str.equals(s);
}
}
Aggregations