Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Type.getValueBitSize in case of a CharType #943

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sootup.core/src/main/java/sootup/core/types/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static int getValueBitSize(Type type) {
if (type instanceof PrimitiveType.ByteType) {
return 8;
}
if (type instanceof PrimitiveType.ShortType) {
if (type instanceof PrimitiveType.ShortType || type instanceof PrimitiveType.CharType) {
return 16;
}
if (type instanceof PrimitiveType.IntType || type instanceof PrimitiveType.FloatType) {
Expand Down
14 changes: 14 additions & 0 deletions sootup.core/src/test/java/sootup/core/types/TypeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package sootup.core.types;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class TypeTest {

@Test
public void testValueBitSize() {
int charValueBitSize = Type.getValueBitSize(PrimitiveType.getChar());
assertEquals(16, charValueBitSize);
}
}