package com.avg.zaap.crashlibrary.publish.cap;

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

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * A test class for {@link CapHelper}.
 * <p>
 * Created by marek.osvald on 18.7.2016.
 */
public class CapHelperTests {

    private static final String CRASH_CODE = "12--3-4--5-67--8-9--0-a--b-c--d-e--f";
    private static final String CRASH_ID = "0x12345678";
    private static final int OFFSET = 123;
    private static final String HEX_OFFSET = "0x7b";

    private ICapHelper mCapHelper;

    @Before
    public void setUp() throws Exception {
        mCapHelper = new CapHelper();
    }

    @Test
    public void getCapCrashIDFromCrashCode_nothing_returnsCapCrashID() throws Exception {
        // act
        final String result = mCapHelper.getExceptionCodeFromCrashCode(CRASH_CODE);

        // assert
        assertThat(result, is(CRASH_ID));
    }

    @Test
    public void getCapFaultingHexOffset_nothing_returnsCapCrashID() throws Exception {
        // act
        final String result = mCapHelper.getCapFaultingHexOffset(OFFSET);

        // assert
        assertThat(result, is(HEX_OFFSET));
    }

}
