Search in sources :

Example 11 with ImmutableExceptionHandler

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

the class TryListBuilderTest method testSingleCatch_Middle.

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

Example 12 with ImmutableExceptionHandler

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

the class TryListBuilderTest method testHandlerMerge_MergeSame.

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

Example 13 with ImmutableExceptionHandler

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

the class TryListBuilderTest method testOverlap_Before_Before.

@Test
public void testOverlap_Before_Before() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(0, 3, new ImmutableExceptionHandler("LException2;", 6));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(0, 3, ImmutableList.of(new ImmutableExceptionHandler("LException2;", 6))), new ImmutableTryBlock(5, 5, 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 14 with ImmutableExceptionHandler

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

the class TryListBuilderTest method testSingleCatchAll_Beginning.

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

Example 15 with ImmutableExceptionHandler

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

the class TryListBuilderTest method testSingleCatch_Beginning.

@Test
public void testSingleCatch_Beginning() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(0, 10, new ImmutableExceptionHandler("Ljava/lang/Exception;", 5));
    List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();
    List<? extends TryBlock> expected = ImmutableList.of(new ImmutableTryBlock(0, 10, ImmutableList.of(new ImmutableExceptionHandler("Ljava/lang/Exception;", 5))));
    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