Skip to content
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 jmeos-core/src/main/java/types/basic/tbool/TBool.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ default Set<Boolean> value_set(){
Pointer resPointer = GeneratedFunctions.tbool_values(this.getBoolInner(), intPointer);
StringBuilder sb = null;
sb.append("{");
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for (int i=0;i<count;i++){
boolean boolRes= false;
int res= resPointer.getInt((long) i *Integer.BYTES);
Expand Down
2 changes: 1 addition & 1 deletion jmeos-core/src/main/java/types/basic/tfloat/TFloat.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ default FloatSet value_set(){
Pointer resPointer = GeneratedFunctions.tfloat_values(this.getNumberInner(), intPointer);
StringBuilder sb = null;
sb.append("{");
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for (int i=0;i<count;i++){
double res= resPointer.getDouble((long) i *Double.BYTES);
sb.append(res);
Expand Down
2 changes: 1 addition & 1 deletion jmeos-core/src/main/java/types/basic/tint/TInt.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ default IntSet value_set(){
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer res= GeneratedFunctions.tint_values(this.getNumberInner(), intPointer);
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
StringBuilder sb = new StringBuilder();
sb.append("{");
for(int i=0;i<count;i++){
Expand Down
4 changes: 2 additions & 2 deletions jmeos-core/src/main/java/types/basic/tnumber/TNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ default List<TNumber> value_split(int size, int start){
Pointer listPointer = createEmptyPointerArray(runtime, size);
Pointer result= GeneratedFunctions.tint_value_split(this.getNumberInner(), size, start, listPointer, intPointer);
List<TNumber> tempList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0;i<count;i++){
Pointer res= result.getPointer((long) i *Long.BYTES);
TNumber t= (TNumber) Factory.create_temporal(res, this.getCustomType(), this.getTemporalType());
Expand Down Expand Up @@ -869,7 +869,7 @@ default List<TNumber> value_time_split(Object duration, int value_size, int valu
Pointer timeListPointer = createEmptyPointerArray(runtime, value_size);
Pointer p= GeneratedFunctions.tint_value_time_split(this.getNumberInner(), value_size, dt, value_start, st, valueListPointer, timeListPointer, intPointer);
List<TNumber> tempList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0;i<count;i++){
Pointer res= p.getPointer((long) i *Long.BYTES);
TNumber t= (TNumber) Factory.create_temporal(res, this.getCustomType(), this.getTemporalType());
Expand Down
6 changes: 3 additions & 3 deletions jmeos-core/src/main/java/types/basic/tpoint/TPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ default List<TPoint> values(int precision){
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.temporal_instants(this.getPointInner(), intPointer);
List<TPoint> pointList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0; i<count; i++){
Pointer res= resPointer.getPointer((long) i *Long.BYTES);
TPoint t= (TPoint) Factory.create_temporal(res, this.getCustomType(), this.getTemporalType());
Expand Down Expand Up @@ -389,7 +389,7 @@ default List<STBox> stboxes(){
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tgeo_stboxes(this.getPointInner(), intPointer);
List<STBox> stBoxList= new ArrayList<>();
int length= intPointer.getInt(Integer.BYTES);
int length= intPointer.getInt(0);
for(int i=0; i<length; i++){
Pointer p= resPointer.getPointer((long) i *Long.BYTES);
STBox b= new STBox(p);
Expand Down Expand Up @@ -550,7 +550,7 @@ default List<TPoint> make_simple(){
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tpoint_make_simple(this.getPointInner(), intPointer);
int length= intPointer.getInt(Integer.BYTES);
int length= intPointer.getInt(0);
List<TPoint> tPointList= new ArrayList<>();
TemporalType temporalType= getTemporalType();
String customType= getCustomType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ default GeographySet value_set(int precision) throws ParseException {
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tgeo_values(this.getPointInner(), intPointer);
List<TPoint> pointList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
StringBuilder sb = null;
sb.append("{");
for(int i=0;i<count;i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ default GeometrySet value_set(int precision) throws ParseException {
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tgeo_values(this.getPointInner(), intPointer);
List<TPoint> pointList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
StringBuilder sb = null;
sb.append("{");
for(int i=0;i<count;i++) {
Expand Down
2 changes: 1 addition & 1 deletion jmeos-core/src/main/java/types/basic/ttext/TText.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ default Set<String> value_set(){
Pointer resPointer= GeneratedFunctions.ttext_values(this.getTextInner(), intPointer);
StringBuilder sb= null;
sb.append("{");
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0; i<count; i++){
Pointer res= resPointer.getPointer((long) i *Long.BYTES);
String resString= GeneratedFunctions.text_to_cstring(res);
Expand Down
2 changes: 1 addition & 1 deletion jmeos-core/src/main/java/types/boxes/STBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ public List<STBox> quad_split_flat(){
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.stbox_quad_split(this.get_inner(), intPointer);
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
List<STBox> stBoxList= new ArrayList<>();
for(int i=0;i<count;i++){
Pointer p= resPointer.getPointer((long) i *Long.BYTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public Integer end_element(){

public Integer element_n(int n) throws Exception {
super.element_n(n);
return Objects.requireNonNull(GeneratedFunctions.intset_value_n(this._inner, n + 1)).getInt(Integer.BYTES);
return Objects.requireNonNull(GeneratedFunctions.intset_value_n(this._inner, n + 1)).getInt(0);
}

public List<Integer> elements(){
Expand Down
4 changes: 2 additions & 2 deletions jmeos-core/src/main/java/types/temporal/Temporal.java
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ public List<Temporal> time_split(Object duration, Object start){
Pointer listPointer = createEmptyPointerArray(runtime);
Pointer p= GeneratedFunctions.temporal_time_split(this.inner, dt, st, listPointer, intPointer);
List<Temporal> tempList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0;i<count;i++){
Pointer res= p.getPointer((long) i *Long.BYTES);
Temporal t= Factory.create_temporal(res, this.getCustomType(), this.getTemporalType());
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public List<Temporal> time_split_n(int n){
Pointer listPointer = createEmptyPointerArray(runtime);
Pointer p= GeneratedFunctions.temporal_time_split(this.inner, dt, st, listPointer, intPointer);
List<Temporal> tempList= new ArrayList<>();
int count= intPointer.getInt(Integer.BYTES);
int count= intPointer.getInt(0);
for(int i=0;i<count;i++){
Pointer res= p.getPointer((long) i *Long.BYTES);
Temporal t= Factory.create_temporal(res, this.getCustomType(), this.getTemporalType());
Expand Down
19 changes: 19 additions & 0 deletions jmeos-core/src/test/java/basic/TGeomPointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1127,4 +1127,23 @@ void testSpaceTimeSplitTimeOrigin() {
assertEquals(2, source.space_time_split(10f, java.time.Duration.ofDays(1),
null, null, null, null, false, false).size());
}


@org.junit.jupiter.api.Test
void testValuesStboxesMakeSimple() {
GeneratedFunctions.meos_initialize_timezone("UTC");
TGeomPointSeq source = new TGeomPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]");
java.util.List<TPoint> values = source.values(6);
assertEquals(2, values.size());
assertEquals("POINT(1 1)@2019-09-01 00:00:00+00", values.get(0).to_string());
assertEquals("POINT(2 2)@2019-09-02 00:00:00+00", values.get(1).to_string());
assertEquals(1, source.stboxes().size());
java.util.List<TPoint> simple = new TGeomPointSeq("[Point(0 0)@2019-09-01, Point(2 2)@2019-09-02, "
+ "Point(2 0)@2019-09-03, Point(0 2)@2019-09-04]").make_simple();
assertEquals(2, simple.size());
assertEquals("[POINT(0 0)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00, "
+ "POINT(2 0)@2019-09-03 00:00:00+00)", simple.get(0).to_string());
assertEquals("[POINT(2 0)@2019-09-03 00:00:00+00, POINT(0 2)@2019-09-04 00:00:00+00]",
simple.get(1).to_string());
}
}
31 changes: 31 additions & 0 deletions jmeos-core/src/test/java/basic/TIntTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,4 +871,35 @@ void testEverGreater(Temporal source, String type, int arg, boolean expected) {
assertEquals(((TInt)source).never_greater_or_equal(arg),expected);
assertEquals(((TInt)source).ever_greater_or_equal(arg),! expected);
}


@org.junit.jupiter.api.Test
void testValueSet() {
GeneratedFunctions.meos_initialize_timezone("UTC");
assertEquals("{1, 2}", new TIntSeq("[1@2019-09-01, 2@2019-09-02]").value_set().toString());
}


@org.junit.jupiter.api.Test
void testValueSplit() {
GeneratedFunctions.meos_initialize_timezone("UTC");
java.util.List<TNumber> fragments = new TIntSeq("[1@2019-09-01, 5@2019-09-02]").value_split(2, 0);
assertEquals(2, fragments.size());
assertEquals("{[1@2019-09-01 00:00:00+00, 1@2019-09-02 00:00:00+00)}", ((TInt) fragments.get(0)).to_string());
assertEquals("{[5@2019-09-02 00:00:00+00]}", ((TInt) fragments.get(1)).to_string());
}


@org.junit.jupiter.api.Test
void testTimeSplit() {
GeneratedFunctions.meos_initialize_timezone("UTC");
TIntSeq source = new TIntSeq("[1@2019-09-01, 5@2019-09-03]");
for (java.util.List<Temporal> fragments : java.util.List.of(
source.time_split(java.time.Duration.ofDays(1), LocalDateTime.of(2019, 9, 1, 0, 0)),
source.time_split_n(2))) {
assertEquals(2, fragments.size());
assertEquals("[1@2019-09-01 00:00:00+00, 1@2019-09-02 00:00:00+00)", ((TInt) fragments.get(0)).to_string());
assertEquals("[1@2019-09-02 00:00:00+00, 5@2019-09-03 00:00:00+00]", ((TInt) fragments.get(1)).to_string());
}
}
}
6 changes: 6 additions & 0 deletions jmeos-core/src/test/java/boxes/STBoxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,10 @@ public void testAdjacent(String stbox, String stbox2, String expected) throws SQ
}
assertEquals(stb.is_adjacent(stb2),res);
}


@org.junit.jupiter.api.Test
public void testQuadSplitFlat() {
assertEquals(4, new STBox("STBOX X((0,0),(4,4))").quad_split_flat().size());
}
}
5 changes: 1 addition & 4 deletions jmeos-core/src/test/java/collections/number/IntSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@ public void testEndElements(){
assertEquals(3, intset.end_element());
}

/*
@Test
public void testElementN() throws Exception {
assertEquals(2, intset.element_n(2));
assertEquals(2, intset.element_n(1));
}

*/

// @Test
// public void testHash() throws Exception {
// assertEquals(3969573766l, intset.hash());
Expand Down
Loading