View Javadoc
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  
18  package org.apache.commons.lang3.arch;
19  
20  import static org.junit.jupiter.api.Assertions.assertFalse;
21  import static org.junit.jupiter.api.Assertions.assertTrue;
22  
23  import org.apache.commons.lang3.AbstractLangTest;
24  import org.apache.commons.lang3.arch.Processor.Arch;
25  import org.apache.commons.lang3.arch.Processor.Type;
26  import org.junit.jupiter.api.Test;
27  
28  class ProcessorTest extends AbstractLangTest {
29  
30      @Test
31      void testIs32Bit() {
32          Processor processor = new Processor(Arch.BIT_32, Type.X86);
33          assertTrue(processor.is32Bit());
34          processor = new Processor(Arch.BIT_64, Type.X86);
35          assertFalse(processor.is32Bit());
36      }
37  
38      @Test
39      void testIs64Bit() {
40          Processor processor = new Processor(Arch.BIT_64, Type.X86);
41          assertTrue(processor.is64Bit());
42          processor = new Processor(Arch.BIT_32, Type.X86);
43          assertFalse(processor.is64Bit());
44      }
45  
46      @Test
47      void testIsAarch64() {
48          Processor processor = new Processor(Arch.BIT_64, Type.AARCH_64);
49          assertTrue(processor.isAarch64());
50          processor = new Processor(Arch.BIT_64, Type.X86);
51          assertFalse(processor.isAarch64());
52      }
53  
54      @Test
55      void testIsIA64() {
56          Processor processor = new Processor(Arch.BIT_64, Type.IA_64);
57          assertTrue(processor.isIA64());
58          processor = new Processor(Arch.BIT_64, Type.X86);
59          assertFalse(processor.isIA64());
60      }
61  
62      @Test
63      void testIsPPC() {
64          Processor processor = new Processor(Arch.BIT_64, Type.PPC);
65          assertTrue(processor.isPPC());
66          processor = new Processor(Arch.BIT_64, Type.X86);
67          assertFalse(processor.isPPC());
68      }
69  
70      @Test
71      void testIsRISCV() {
72          Processor processor = new Processor(Arch.BIT_64, Type.RISC_V);
73          assertTrue(processor.isRISCV());
74          processor = new Processor(Arch.BIT_64, Type.X86);
75          assertFalse(processor.isRISCV());
76      }
77  
78      @Test
79      void testIsX86() {
80          Processor processor = new Processor(Arch.BIT_32, Type.X86);
81          assertTrue(processor.isX86());
82          processor = new Processor(Arch.BIT_64, Type.AARCH_64);
83          assertFalse(processor.isX86());
84      }
85  }