/**
 * Copyright © 2021 by Data Virtuality GmbH
 */

package org.teiid.core.types.basic;

import org.junit.jupiter.api.Test;
import org.teiid.core.types.BinaryType;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SuppressWarnings("nls")
public class TestStringToBinaryTypeTransform {

    @Test
    public void testHexEvenChars() throws Exception {
        String chars = "1A3D5F";
        StringToBinaryTypeTransform transform = new StringToBinaryTypeTransform();

        BinaryType returned = (BinaryType) transform.transformDirect(chars);

        assertEquals("1A3D5F", returned.toString());
    }
    
    @Test
    public void testHexOddChars() throws Exception {
        String chars = "1A3D5";
        StringToBinaryTypeTransform transform = new StringToBinaryTypeTransform();

        BinaryType returned = (BinaryType) transform.transformDirect(chars);

        assertEquals(new BinaryType("1A3D5".getBytes()), returned);
    }

    @Test
    public void testNonHexChars() throws Exception {
        String chars = "1A3D5X";
        StringToBinaryTypeTransform transform = new StringToBinaryTypeTransform();

        BinaryType returned = (BinaryType) transform.transformDirect(chars);

        assertEquals(new BinaryType("1A3D5X".getBytes()), returned);
    }

}
