aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/apache/commons/bcel6/generic/InstructionHandleTestCase.java
blob: ab9d786c49f71d845c92e8f852f3b3b133d02a5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.apache.commons.bcel6.generic;

import org.junit.Assert;
import org.junit.Test;

public class InstructionHandleTestCase {

    // Test that setInstruction only allows Instructions that are not BranchInstructions

    @Test(expected=ClassGenException.class)
    public void testsetInstructionNull() {
        InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
        Assert.assertNotNull(ih);
        ih.setInstruction(null);
        Assert.assertNotNull(ih);
    }

    @Test
    public void testsetInstructionI() {
        InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
        Assert.assertNotNull(ih);
        ih.setInstruction(new NOP());        
        Assert.assertNotNull(ih);
    }

    @Test(expected=ClassGenException.class)
    public void testsetInstructionnotI() {
        InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
        Assert.assertNotNull(ih);
        ih.setInstruction(new GOTO(null));        
        Assert.assertNotNull(ih);
    }

    @Test(expected=ClassGenException.class)
    public void testGetIHnull() {
        InstructionHandle.getInstructionHandle(null); 
    }

    @Test
    public void testBCEL195() {
        InstructionList il = new InstructionList();
        InstructionHandle ih = il.append(InstructionConst.NOP);
        new TABLESWITCH(new int[0], new InstructionHandle[0], ih);
        new TABLESWITCH(new int[0], new InstructionHandle[0], ih);
    }
}