Skip to content

Commit 5db0618

Browse files
Test: Improve branch coverage for Processor.java (isAarch64, isRISCV) (#1578)
* Test: Improve branch coverage for Processor.java (isAarch64, isRISCV) * File should end in a blank line. * Test: Add coverage for all is* methods in Processor --------- Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
1 parent 4ba46c6 commit 5db0618

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.commons.lang3.arch;
18+
19+
import static org.junit.jupiter.api.Assertions.assertFalse;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
22+
import org.apache.commons.lang3.arch.Processor.Arch;
23+
import org.apache.commons.lang3.arch.Processor.Type;
24+
import org.junit.jupiter.api.Test;
25+
26+
public class ProcessorTest {
27+
28+
@Test
29+
public void testIs32Bit() {
30+
Processor processor = new Processor(Arch.BIT_32, Type.X86);
31+
assertTrue(processor.is32Bit());
32+
33+
processor = new Processor(Arch.BIT_64, Type.X86);
34+
assertFalse(processor.is32Bit());
35+
}
36+
37+
@Test
38+
public void testIs64Bit() {
39+
Processor processor = new Processor(Arch.BIT_64, Type.X86);
40+
assertTrue(processor.is64Bit());
41+
42+
processor = new Processor(Arch.BIT_32, Type.X86);
43+
assertFalse(processor.is64Bit());
44+
}
45+
46+
@Test
47+
public void testIsAarch64() {
48+
Processor processor = new Processor(Arch.BIT_64, Type.AARCH_64);
49+
assertTrue(processor.isAarch64());
50+
51+
processor = new Processor(Arch.BIT_64, Type.X86);
52+
assertFalse(processor.isAarch64());
53+
}
54+
55+
@Test
56+
public void testIsIA64() {
57+
Processor processor = new Processor(Arch.BIT_64, Type.IA_64);
58+
assertTrue(processor.isIA64());
59+
60+
processor = new Processor(Arch.BIT_64, Type.X86);
61+
assertFalse(processor.isIA64());
62+
}
63+
64+
@Test
65+
public void testIsPPC() {
66+
Processor processor = new Processor(Arch.BIT_64, Type.PPC);
67+
assertTrue(processor.isPPC());
68+
69+
processor = new Processor(Arch.BIT_64, Type.X86);
70+
assertFalse(processor.isPPC());
71+
}
72+
73+
@Test
74+
public void testIsRISCV() {
75+
Processor processor = new Processor(Arch.BIT_64, Type.RISC_V);
76+
assertTrue(processor.isRISCV());
77+
78+
processor = new Processor(Arch.BIT_64, Type.X86);
79+
assertFalse(processor.isRISCV());
80+
}
81+
82+
@Test
83+
public void testIsX86() {
84+
Processor processor = new Processor(Arch.BIT_32, Type.X86);
85+
assertTrue(processor.isX86());
86+
87+
processor = new Processor(Arch.BIT_64, Type.AARCH_64);
88+
assertFalse(processor.isX86());
89+
}
90+
}

0 commit comments

Comments
 (0)