Search in sources :

Example 21 with ImmutableExceptionHandler

use of org.jf.dexlib2.immutable.ImmutableExceptionHandler in project smali by JesusFreke.

the class TryListBuilderTest method testOverlap_Middle_Middle.

@Test
public void testOverlap_Middle_Middle() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(0, 10, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(2, 7, new ImmutableExceptionHandler("LException2;", 6));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(0, 2, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5))), new ImmutableTryBlock(2, 5, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5), new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(7, 3, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5))));
    Assert.assertEquals(expected, tryBlocks);
}
Also used : ImmutableTryBlock(org.jf.dexlib2.immutable.ImmutableTryBlock) ImmutableExceptionHandler(org.jf.dexlib2.immutable.ImmutableExceptionHandler) Test(org.junit.Test)

Example 22 with ImmutableExceptionHandler

use of org.jf.dexlib2.immutable.ImmutableExceptionHandler in project smali by JesusFreke.

the class TryListBuilderTest method testOverlap_Beginning_After.

@Test
public void testOverlap_Beginning_After() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(0, 10, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException2;", 6));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(0, 10, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5), new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(10, 5, ImmutableList.of(new ImmutableExceptionHandler("LException2;", 6))));
    Assert.assertEquals(expected, tryBlocks);
}
Also used : ImmutableTryBlock(org.jf.dexlib2.immutable.ImmutableTryBlock) ImmutableExceptionHandler(org.jf.dexlib2.immutable.ImmutableExceptionHandler) Test(org.junit.Test)

Example 23 with ImmutableExceptionHandler

use of org.jf.dexlib2.immutable.ImmutableExceptionHandler in project smali by JesusFreke.

the class TryListBuilderTest method testOverlap_Hole.

@Test
public void testOverlap_Hole() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(1, 5, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(10, 14, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException2;", 6));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(0, 1, ImmutableList.of(new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(1, 4, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5), new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(5, 5, ImmutableList.of(new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(10, 4, ImmutableList.of(new ImmutableExceptionHandler("LException1;", 5), new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(14, 1, ImmutableList.of(new ImmutableExceptionHandler("LException2;", 6))));
    Assert.assertEquals(expected, tryBlocks);
}
Also used : ImmutableTryBlock(org.jf.dexlib2.immutable.ImmutableTryBlock) ImmutableExceptionHandler(org.jf.dexlib2.immutable.ImmutableExceptionHandler) Test(org.junit.Test)

Example 24 with ImmutableExceptionHandler

use of org.jf.dexlib2.immutable.ImmutableExceptionHandler in project smali by JesusFreke.

the class TryListBuilderTest method testHandlerMerge_Catchall_Catchall_DifferentAddress.

@Test
public void testHandlerMerge_Catchall_Catchall_DifferentAddress() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(5, 10, new ImmutableExceptionHandler(null, 5));
    try {
        tlb.addHandler(0, 15, new ImmutableExceptionHandler(null, 6));
    } catch (TryListBuilder.InvalidTryException ex) {
        return;
    }
    Assert.fail();
}
Also used : ImmutableExceptionHandler(org.jf.dexlib2.immutable.ImmutableExceptionHandler) Test(org.junit.Test)

Example 25 with ImmutableExceptionHandler

use of org.jf.dexlib2.immutable.ImmutableExceptionHandler in project smali by JesusFreke.

the class TryListBuilderTest method testSingleCatchAll_Middle.

@Test
public void testSingleCatchAll_Middle() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(5, 10, new ImmutableExceptionHandler(null, 15));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(5, 5, ImmutableList.of(new ImmutableExceptionHandler(null, 15))));
    Assert.assertEquals(expected, tryBlocks);
}
Also used : ImmutableTryBlock(org.jf.dexlib2.immutable.ImmutableTryBlock) ImmutableExceptionHandler(org.jf.dexlib2.immutable.ImmutableExceptionHandler) Test(org.junit.Test)

Aggregations

ImmutableExceptionHandler (org.jf.dexlib2.immutable.ImmutableExceptionHandler)26 Test (org.junit.Test)26 ImmutableTryBlock (org.jf.dexlib2.immutable.ImmutableTryBlock)24