Search in sources :

Example 6 with ImmutableTryBlock

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

the class TryListBuilderTest method testOverlap_End_After.

@Test
public void testOverlap_End_After() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(0, 10, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(10, 20, 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 ImmutableTryBlock(10, 10, 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 7 with ImmutableTryBlock

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

the class TryListBuilderTest method testOverlap_Middle_End.

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

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

the class TryListBuilderTest method testOverlap_After_After.

@Test
public void testOverlap_After_After() {
    TryListBuilder tlb = new TryListBuilder();
    tlb.addHandler(0, 10, new ImmutableExceptionHandler("LException1;", 5));
    tlb.addHandler(15, 20, 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 ImmutableTryBlock(15, 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 9 with ImmutableTryBlock

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

the class TryListBuilderTest method testHandlerMerge_Exception_Catchall.

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

use of org.jf.dexlib2.immutable.ImmutableTryBlock 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)

Aggregations

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