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