Skip to content

Commit

Permalink
Update testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Sep 22, 2024
1 parent 2a10c7e commit 5dae39c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.gnome.gobject.Value;
import org.junit.jupiter.api.Test;

import java.lang.foreign.Arena;

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

Expand All @@ -39,31 +37,31 @@ public class ValueTest {
@Test
public void booleanValue() {
boolean b = true;
Value boolValue = Value.allocate(Arena.ofAuto()).init(Types.BOOLEAN);
Value boolValue = new Value().init(Types.BOOLEAN);
boolValue.setBoolean(b);
assertEquals(boolValue.getBoolean(), b);
}

@Test
public void doubleValue() {
double d = 12345.6789;
Value doubleValue = Value.allocate(Arena.ofAuto()).init(Types.DOUBLE);
Value doubleValue = new Value().init(Types.DOUBLE);
doubleValue.setDouble(d);
assertEquals(doubleValue.getDouble(), d);
}

@Test
public void floatValue() {
float f = 12.345f;
Value floatValue = Value.allocate(Arena.ofAuto()).init(Types.FLOAT);
Value floatValue = new Value().init(Types.FLOAT);
floatValue.setFloat(f);
assertEquals(floatValue.getFloat(), f);
}

@Test
public void intValue() {
int i = 15;
Value intValue = Value.allocate(Arena.ofAuto()).init(Types.INT);
Value intValue = new Value().init(Types.INT);
intValue.setInt(i);
assertEquals(intValue.getInt(), i);
}
Expand All @@ -72,15 +70,15 @@ public void intValue() {
public void longValue() {
// long values are marshaled to int, for Windows compatibility.
int i = 15;
Value longValue = Value.allocate(Arena.ofAuto()).init(Types.LONG);
Value longValue = new Value().init(Types.LONG);
longValue.setLong(i);
assertEquals(longValue.getLong(), i);
}

@Test
public void stringValue() {
String s = "Test";
Value strValue = Value.allocate(Arena.ofAuto()).init(Types.STRING);
Value strValue = new Value().init(Types.STRING);
strValue.setString(s);
assertEquals(strValue.getString(), s);
}
Expand All @@ -89,7 +87,7 @@ public void stringValue() {
public void objectValue() {
// value.getObject() == o, because getObject() will retrieve o from the InstanceCache
GObject o = new SimpleAction("test", null);
Value objValue = Value.allocate(Arena.ofAuto()).init(Types.OBJECT);
Value objValue = new Value().init(Types.OBJECT);
objValue.setObject(o);
assertEquals(objValue.getObject(), o);
}
Expand All @@ -98,7 +96,7 @@ public void objectValue() {
public void boxedValue() {
// compare a boxed value with its duplicate
Date date = Date.dmy(new DateDay((byte) 3), DateMonth.JUNE, new DateYear((short) 2023));
Value boxedValue = Value.allocate(Arena.ofAuto()).init(Date.getType());
Value boxedValue = new Value().init(Date.getType());
boxedValue.setBoxed(date.handle());
var copy = boxedValue.dupBoxed();
assertNotNull(copy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.gnome.gobject.WeakRef;
import org.junit.jupiter.api.Test;

import java.lang.foreign.Arena;

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

/**
Expand All @@ -36,8 +34,7 @@ public class WeakRefTest {
public void createWeakRef() {
SimpleAction gobject = new SimpleAction("test", null);

@SuppressWarnings("unchecked")
WeakRef<SimpleAction> weakRef = WeakRef.allocate(Arena.ofAuto());
WeakRef<SimpleAction> weakRef = new WeakRef<>();
weakRef.init(gobject);

SimpleAction action2 = weakRef.get();
Expand Down

0 comments on commit 5dae39c

Please sign in to comment.