I can''t tell how you're comparing the strings as the I don't see
where the assertion happens.

But if you're just doing a assertEquals with two byte arrays it won't
work, you'll have to do assertArrayEqauls instead.

Tim

On Sat, May 17, 2014 at 10:53 AM, Yash Sharma <[email protected]> wrote:
> Hi All,
> While implementing the toascii(inputStr, encodingType) I am receiving this
> assertion error. I have tried using different styles for passing the
> assertion string in test case but this always fails with below error. Have
> tried StackOverflow but not able to get it working.
>
> Any tips would be appreciated. This is blocking me from putting my patch on
> review board -
>
> Peace,
> Yash
>
>
> -------------------------------------------------------------------------------------------
> maven failure
> -------------------------------------------------------------------------------------------
> âpple âpple
> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 12.001 sec
> <<< FAILURE! - in org.apache.drill.exec.physical.impl.TestStringFunctions
> testNewStringFuncs(org.apache.drill.exec.physical.impl.TestStringFunctions)
>  Time elapsed: 4.04 sec  <<< FAILURE!
> org.junit.ComparisonFailure: column 8 does not match expected:<âpple[]>
> but was:<âpple[]>
>
>
>
> -------------------------------------------------------------------------------------------
> string function implementation
> -------------------------------------------------------------------------------------------
> @FunctionTemplate(name = "toascii", scope = FunctionScope.SIMPLE, nulls =
> NullHandling.NULL_IF_NULL)
> public static class AsciiEndode implements DrillSimpleFunc {
>
>   @Param  VarCharHolder in;
>   @Param  VarCharHolder enc;
>   @Output VarCharHolder out;
>
>   public void setup(RecordBatch incoming) {
>   }
>
>   public void eval() {
>
>    byte[] bytea = new byte[in.end - in.start +1];
>    int index =0;
>    for(int i = in.start; i<in.end; i++, index++){
>    bytea[index]=in.buffer.getByte(i);
>    }
>     byte[] bytes = new String(bytea,
> java.nio.charset.Charset.forName(enc.toString())).getBytes(java.nio.charset.Charset.forName("UTF-8"));
>
>  out.buffer = io.netty.buffer.Unpooled.wrappedBuffer(new byte [8000]);
>  out.start = 0;
>  out.buffer.setBytes(out.start, bytes);
>  out.end = bytes.length;
>   }
> }
>
>
> -------------------------------------------------------------------------------------------
> test case
> -------------------------------------------------------------------------------------------
>
> @Test
>   public void testNewStringFuncs(@Injectable final DrillbitContext
> bitContext,
>                            @Injectable UserServer.UserClientConnection
> connection) throws Throwable{
>     Object [] expected = new Object[] {97, 65, -32, "A", "trim", "Peace
> Peace Peace ", "हकुना मताता हकुना मताता ", "katcit", "\u00C3\u00A2pple"};
>
>     runTest(bitContext, connection, expected,
> "functions/string/testStringFuncs.json");
>   }
>
> -------------------------------------------------------------------------------------------
> call in physical plan
> -------------------------------------------------------------------------------------------
>  { ref : "ref9", expr : " toascii('âpple','ISO-8859-1') "}

Reply via email to