|
25 | 25 | import static org.junit.Assert.assertThat;
|
26 | 26 | import static org.junit.Assert.fail;
|
27 | 27 |
|
| 28 | +import java.io.UnsupportedEncodingException; |
28 | 29 | import java.math.BigInteger;
|
| 30 | +import java.nio.charset.Charset; |
29 | 31 | import java.util.Date;
|
30 | 32 |
|
31 | 33 | import org.junit.Test;
|
@@ -914,7 +916,28 @@ public void addBitInteger() {
|
914 | 916 | @Test
|
915 | 917 | public void objectWithByteSize256() {
|
916 | 918 | final StringBuilder aa = new StringBuilder();
|
917 |
| - final int stringLength = 231; |
| 919 | + final int stringLength = 256 - 25; |
| 920 | + for (int i = 0; i < stringLength; ++i) { |
| 921 | + aa.append("a"); |
| 922 | + } |
| 923 | + final String foo = "foo"; |
| 924 | + final String bar1 = "bar1"; |
| 925 | + final String bar2 = "bar2"; |
| 926 | + final VPackSlice vpack = new VPackBuilder().add(ValueType.OBJECT).add(foo, ValueType.OBJECT).add(bar2, "") |
| 927 | + .add(bar1, aa.toString()).close().close().slice(); |
| 928 | + |
| 929 | + assertThat(vpack.isObject(), is(true)); |
| 930 | + assertThat(vpack.get(foo).isObject(), is(true)); |
| 931 | + assertThat(vpack.get(foo).get(bar1).isString(), is(true)); |
| 932 | + assertThat(vpack.get(foo).get(bar1).getLength(), is(stringLength)); |
| 933 | + assertThat(vpack.get(foo).get(bar2).isString(), is(true)); |
| 934 | + assertThat(vpack.get(foo).get(bar2).getLength(), is(0)); |
| 935 | + } |
| 936 | + |
| 937 | + @Test |
| 938 | + public void objectWithByteSizeOver65536() { |
| 939 | + final StringBuilder aa = new StringBuilder(); |
| 940 | + final int stringLength = 65536 - 25 - 8; |
918 | 941 | for (int i = 0; i < stringLength; ++i) {
|
919 | 942 | aa.append("a");
|
920 | 943 | }
|
|
0 commit comments