package com.eqot.fontawesome;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.text.SpannableStringBuilder;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.lang.reflect.Method;

import static junit.framework.Assert.assertEquals;

public class FontAwesomeTest {
    private Method convertText;

    private Context mContext;

    @Before
    public void setUp() throws Exception {
        convertText = FontAwesome.class.getDeclaredMethod(
                "convertText", Context.class, CharSequence.class);
        convertText.setAccessible(true);

        mContext = InstrumentationRegistry.getTargetContext();
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void convertTextWithCode() throws Exception {
        SpannableStringBuilder sb = (SpannableStringBuilder) convertText.invoke(null,
                mContext, "foo {fa-thumbs-o-up} bar");
        assertEquals("foo \uf087 bar", sb.toString());
    }

    @Test
    public void convertTextWithTwoCodes() throws Exception {
        SpannableStringBuilder sb = (SpannableStringBuilder) convertText.invoke(null,
                mContext, "foo {fa-thumbs-o-up} bar {fa-smile-o} baz");
        assertEquals("foo \uf087 bar \uf118 baz", sb.toString());
    }

    @Test
    public void convertTextWithoutCode() throws Exception {
        SpannableStringBuilder sb = (SpannableStringBuilder) convertText.invoke(null,
                mContext, "foo");
        assertEquals("foo", sb.toString());
    }
}
@@ -371,24 +371,65 @@
 convertText;
+%0A    private Method getCharacterFromCode;
 %0A%0A    privat
@@ -672,16 +672,205 @@
 true);%0A%0A
+        getCharacterFromCode = FontAwesome.class.getDeclaredMethod(%0A                %22getCharacterFromCode%22, Context.class, String.class);%0A        getCharacterFromCode.setAccessible(true);%0A%0A
         
@@ -1807,10 +1807,227 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void getCharacterFromCode() throws Exception %7B%0A        String character = (String) getCharacterFromCode.invoke(null, mContext, %22fa-thumbs-o-up%22);%0A        assertEquals(%22%5Cuf087%22, character);%0A    %7D
 %0A%7D

Add test