Skip to content

Instantly share code, notes, and snippets.

@ajuckel
Created September 26, 2011 19:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ajuckel/1243195 to your computer and use it in GitHub Desktop.
Test invalid utf-8 parsing
public void testGetUnicodeValue() throws Exception {
byte[] bytes = new byte[] {
110, 122, -31, 32, 75
};
RubyString str = RubyString.newStringLight(Ruby.getGlobalRuntime(), new ByteList(bytes));
assertEquals(5, ((Integer)str.length().toJava(Integer.class)).intValue());
assertEquals(5, str.getUnicodeValue().length());
}
// In RubyEncodings:
CoderResult res = decoder.decode(buffer, cbuffer, true);
if( res.isError() ) {
res.throwException();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment