Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding of string length #138

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public byte[] getObject(long index) {
int length = 0;
do {
b = data.getByte(offset++);
length |= (b & 0x7F) << pos++;
length |= (b & 0x7F) << pos;
pos += 7;
} while ((b & 0x80) != 0);

// Read string of the given length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ public void createScalar() {
assertEquals("Pretty vacant", data.getObject());
}

@Test
@Test
public void createrScalarLongerThan127() {
Tensor<TString> tensor = TString.scalarOf("Long String 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 !");
assertNotNull(tensor);

TString data = tensor.data();
assertNotNull(data);
assertEquals(Shape.scalar(), data.shape());
assertEquals("Long String 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 !", data.getObject());
}


@Test
public void createVector() {
Tensor<TString> tensor = TString.vectorOf("Pretty", "vacant");
assertNotNull(tensor);
Expand Down