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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
uses: MobilityDB/MEOS-API/.github/actions/check-test-outcome@master
with:
log: test.log
min-tests: "103"
min-tests: "106"

- name: Smoke-test the FFI
run: dotnet run --project ExampleApp/ExampleApp.csproj -c Release --no-build
Expand Down
6 changes: 3 additions & 3 deletions ExampleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
try
{
Console.WriteLine("Reading a temporal float instant from \"25.0@2024-12-06\"");
Temporal tfi = TFloat.In("25.0@2024-12-06")!;
Temporal tfi = TFloat.FromText("25.0@2024-12-06")!;
Console.WriteLine($" class : {tfi.GetType().Name}");
Console.WriteLine($" text : {tfi}");
Console.WriteLine($" start timestamp : {tfi.StartTimestamptz():u}");
Expand All @@ -24,7 +24,7 @@
Console.WriteLine($" always <= 30.0? : {Meos.AlwaysLeTfloatFloat(sum.Ptr, 30.0) == 1}\n");

Console.WriteLine("Reading a float span set from \"{[8, 10], [11, 12]}\"");
SpanSet spanset = FloatSpanSet.In("{[8, 10], [11, 12]}")!;
SpanSet spanset = FloatSpanSet.FromText("{[8, 10], [11, 12]}")!;
Console.WriteLine($" class : {spanset.GetType().Name}");
Console.WriteLine($" spans : {spanset.NumSpans()}");
foreach (Span? span in spanset.Spanarr())
Expand All @@ -36,7 +36,7 @@
Console.WriteLine($" width : {((FloatSpanSet)spanset).Width(false)}\n");

Console.WriteLine("Reading a temporal float instant from \"e25.0@2024-12-06\"");
TFloat.In("e25.0@2024-12-06");
TFloat.FromText("e25.0@2024-12-06");
}
catch (MEOSException e)
{
Expand Down
6 changes: 3 additions & 3 deletions MEOS.NET.Tests/ArrayArgumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public void AJsonbIsQueriedWithAnArrayOfKeysWhoseLengthIsNotNamedCount()
{
// `jsonb_exists_array(jb, text **keys_elems, int keys_len, bool any)`
// — the length is `keys_len`, and the catalog is what says so.
Jsonb jb = Jsonb.In("{\"a\": 1, \"b\": 2}")!;
Text[] keys = { Text.In("a")!, Text.In("z")! };
Jsonb jb = Jsonb.FromText("{\"a\": 1, \"b\": 2}")!;
Text[] keys = { Text.FromCstring("a")!, Text.FromCstring("z")! };

Assert.IsTrue(jb.ExistsArray(keys, true));
Assert.IsFalse(jb.ExistsArray(keys, false));

Text[] missing = { Text.In("y")!, Text.In("z")! };
Text[] missing = { Text.FromCstring("y")!, Text.FromCstring("z")! };

Assert.IsFalse(jb.ExistsArray(missing, true));
}
Expand Down
10 changes: 5 additions & 5 deletions MEOS.NET.Tests/BorrowedStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ public class BorrowedStringTests : MeosTest
[TestMethod]
public void InterpolationOfALinearSequenceIsRead()
{
Temporal temp = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;
Temporal temp = TFloat.FromText("[25.0@2024-12-06, 27.0@2024-12-07]")!;

Assert.AreEqual("Linear", temp.Interp());
}

[TestMethod]
public void InterpolationOfADiscreteSequenceIsRead()
{
Temporal temp = TFloat.In("{25.0@2024-12-06, 27.0@2024-12-07}")!;
Temporal temp = TFloat.FromText("{25.0@2024-12-06, 27.0@2024-12-07}")!;

Assert.AreEqual("Discrete", temp.Interp());
}

[TestMethod]
public void TheSameBorrowedNameIsReadableTwice()
{
Temporal first = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;
Temporal second = TFloat.In("[1.0@2024-12-06, 2.0@2024-12-07]")!;
Temporal first = TFloat.FromText("[25.0@2024-12-06, 27.0@2024-12-07]")!;
Temporal second = TFloat.FromText("[1.0@2024-12-06, 2.0@2024-12-07]")!;

Assert.AreEqual(first.Interp(), second.Interp());
}

[TestMethod]
public void SubtypeOfASequenceIsRead()
{
Temporal temp = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;
Temporal temp = TFloat.FromText("[25.0@2024-12-06, 27.0@2024-12-07]")!;

Assert.AreEqual("Sequence", temp.Subtype());
}
Expand Down
6 changes: 3 additions & 3 deletions MEOS.NET.Tests/ByteBufferTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ByteBufferTests : MeosTest
[TestMethod]
public void ASpanRoundTripsThroughItsOwnWKB()
{
Span span = FloatSpan.In("[8, 10]")!;
Span span = FloatSpan.FromText("[8, 10]")!;

byte[]? wkb = span.AsWKB(0);

Expand All @@ -28,7 +28,7 @@ public void ASpanRoundTripsThroughItsOwnWKB()
[TestMethod]
public void ATemporalValueRoundTripsThroughItsOwnWKB()
{
Temporal temp = TFloat.In("[25.5@2024-12-06, 27.5@2024-12-08]")!;
Temporal temp = TFloat.FromText("[25.5@2024-12-06, 27.5@2024-12-08]")!;

byte[]? wkb = temp.AsWKB(0);

Expand All @@ -43,7 +43,7 @@ public void ATemporalValueRoundTripsThroughItsOwnWKB()
[TestMethod]
public void TheHexFormNeedsNoLengthOfItsOwn()
{
Span span = FloatSpan.In("[8, 10]")!;
Span span = FloatSpan.FromText("[8, 10]")!;

string hex = span.AsHexWKB(0);

Expand Down
10 changes: 5 additions & 5 deletions MEOS.NET.Tests/CatalogTypedefTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CatalogTypedefTests : MeosTest
[TestMethod]
public void ADatumCrossesAsAnUnsignedWord()
{
Set set = BigIntSet.In("{-1, 7}")!;
Set set = BigIntSet.FromText("{-1, 7}")!;

ulong[] values = Meos.SetValues(set.Ptr);

Expand All @@ -26,18 +26,18 @@ public void ADatumCrossesAsAnUnsignedWord()
[TestMethod]
public void AnOidCrossesAsAnUnsignedInt()
{
Text a = Text.In("abc")!;
Text b = Text.In("abd")!;
Text a = Text.FromCstring("abc")!;
Text b = Text.FromCstring("abd")!;

// 100 is DEFAULT_COLLATION_OID.
Assert.IsTrue(Meos.TextCmp(a.Ptr, b.Ptr, 100u) < 0);
Assert.AreEqual(a.Hash(100u), Text.In("abc")!.Hash(100u));
Assert.AreEqual(a.Hash(100u), Text.FromCstring("abc")!.Hash(100u));
}

[TestMethod]
public void AStructFieldTypedThroughATypedefIsLaidOut()
{
STBox box = STBox.In("STBOX X((1.0,2.0),(3.0,4.0))")!;
STBox box = STBox.FromText("STBOX X((1.0,2.0),(3.0,4.0))")!;

GBOX gbox = box.ToGbox()!.Value;

Expand Down
2 changes: 1 addition & 1 deletion MEOS.NET.Tests/CatalogValueTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CatalogValueTypeTests : MeosTest
[TestMethod]
public void AnEnumArgumentIsTheTextMeosReadsThroughItsPair()
{
TJsonb temp = (TJsonb)TJsonb.In(
TJsonb temp = (TJsonb)TJsonb.FromText(
"[{\"a\": [1, 2]}@2024-12-06, {\"a\": [1, 2]}@2024-12-08]")!;

// The handling of a SQL NULL is passed as the SQL functions take it,
Expand Down
18 changes: 9 additions & 9 deletions MEOS.NET.Tests/CountedArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public void ASequenceIsMadeOfItsInstants()
{
Temporal[] instants =
[
TFloat.In("25.0@2024-12-06")!,
TFloat.In("27.0@2024-12-07")!,
TFloat.In("30.0@2024-12-09")!,
TFloat.FromText("25.0@2024-12-06")!,
TFloat.FromText("27.0@2024-12-07")!,
TFloat.FromText("30.0@2024-12-09")!,
];

// The interpolation is passed as text, which interptype_from_string reads.
Expand All @@ -36,8 +36,8 @@ public void ASpanSetIsMadeOfItsSpans()
// as pointers to them.
Span[] spans =
[
FloatSpan.In("[1.0, 2.0]")!,
FloatSpan.In("[3.0, 4.0]")!,
FloatSpan.FromText("[1.0, 2.0]")!,
FloatSpan.FromText("[3.0, 4.0]")!,
];

SpanSet set = SpanSet.Make(spans)!;
Expand All @@ -53,8 +53,8 @@ public void ACbufferSetIsMadeOfItsCircularBuffers()
// another.
CBuffer[] values =
[
CBuffer.In("Cbuffer(Point(1 1),0.5)")!,
CBuffer.In("Cbuffer(Point(2 2),1.5)")!,
CBuffer.FromText("Cbuffer(Point(1 1),0.5)")!,
CBuffer.FromText("Cbuffer(Point(2 2),1.5)")!,
];

Set set = CBufferSet.Make(values)!;
Expand All @@ -69,8 +69,8 @@ public void MergingAnArrayOfTemporalValuesJoinsThem()
{
Temporal[] parts =
[
TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!,
TFloat.In("[30.0@2024-12-09, 32.0@2024-12-10]")!,
TFloat.FromText("[25.0@2024-12-06, 27.0@2024-12-07]")!,
TFloat.FromText("[30.0@2024-12-09, 32.0@2024-12-10]")!,
];

Temporal merged = Temporal.MergeArray(parts)!;
Expand Down
6 changes: 3 additions & 3 deletions MEOS.NET.Tests/ExtendedWkbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace MEOS.NET.Tests
[TestClass]
public class ExtendedWkbTests : MeosTest
{
private const string Line = "SRID=4326;LINESTRING(1 1, 2 2, 3 4)";
private const string Line = "LINESTRING(1 1, 2 2, 3 4)";

[TestMethod]
public void TheBufferIsAsLongAsTheHexFormSays()
{
Geo line = Geometry.In(Line, -1)!;
Geo line = Geo.FromText(Line, 4326)!;

byte[]? ewkb = line.AsEWKB("ndr");
string hex = line.AsHexEWKB("ndr");
Expand All @@ -28,7 +28,7 @@ public void TheBufferIsAsLongAsTheHexFormSays()
[TestMethod]
public void AGeometryRoundTripsThroughItsOwnEWKB()
{
Geo line = Geometry.In(Line, -1)!;
Geo line = Geo.FromText(Line, 4326)!;

Geo? read = Geo.FromEWKB(line.AsEWKB("ndr")!, 4326);

Expand Down
26 changes: 13 additions & 13 deletions MEOS.NET.Tests/GeneratedObjectLayerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ public class GeneratedObjectLayerTests : MeosTest
[TestMethod]
public void InstantTextGivesTheConcreteInstantClass()
{
Temporal? temp = TFloat.In(Instant);
Temporal? temp = TFloat.FromText(Instant);

Assert.IsInstanceOfType(temp, typeof(TFloatInst));
}

[TestMethod]
public void SequenceTextGivesTheConcreteSequenceClass()
{
Temporal? temp = TFloat.In(Sequence);
Temporal? temp = TFloat.FromText(Sequence);

Assert.IsInstanceOfType(temp, typeof(TFloatSeq));
}

[TestMethod]
public void SequenceHoldsItsTwoInstants()
{
Temporal temp = TFloat.In(Sequence)!;
Temporal temp = TFloat.FromText(Sequence)!;

Assert.AreEqual(2, temp.NumInstants());
Assert.AreEqual("Linear", temp.Interp());
Expand All @@ -44,7 +44,7 @@ public void SequenceHoldsItsTwoInstants()
[TestMethod]
public void StartTimestamptzIsTheMomentTheTextNames()
{
Temporal temp = TFloat.In(Sequence)!;
Temporal temp = TFloat.FromText(Sequence)!;

Assert.AreEqual(new DateTime(2024, 12, 6, 0, 0, 0, DateTimeKind.Utc),
temp.StartTimestamptz().ToUniversalTime());
Expand All @@ -53,7 +53,7 @@ public void StartTimestamptzIsTheMomentTheTextNames()
[TestMethod]
public void RestrictingToAnInstantGivesThatInstant()
{
Temporal temp = TFloat.In(Sequence)!;
Temporal temp = TFloat.FromText(Sequence)!;
DateTime start = temp.StartTimestamptz();

Temporal? at = temp.AtTimestamptz(start);
Expand All @@ -65,7 +65,7 @@ public void RestrictingToAnInstantGivesThatInstant()
[TestMethod]
public void ValueSpanOfTheSequenceIsItsFloatExtent()
{
TNumber temp = (TNumber)TFloat.In(Sequence)!;
TNumber temp = (TNumber)TFloat.FromText(Sequence)!;

Span span = temp.ToSpan()!;

Expand All @@ -77,7 +77,7 @@ public void ValueSpanOfTheSequenceIsItsFloatExtent()
[TestMethod]
public void SpanSetTextGivesTheConcreteFloatSpanSet()
{
SpanSet? spanset = FloatSpanSet.In(SpanSetText);
SpanSet? spanset = FloatSpanSet.FromText(SpanSetText);

Assert.IsInstanceOfType(spanset, typeof(FloatSpanSet));
Assert.AreEqual(2, spanset!.NumSpans());
Expand All @@ -86,7 +86,7 @@ public void SpanSetTextGivesTheConcreteFloatSpanSet()
[TestMethod]
public void EachSpanOfTheSetIsTheSpanTheTextNames()
{
SpanSet spanset = FloatSpanSet.In(SpanSetText)!;
SpanSet spanset = FloatSpanSet.FromText(SpanSetText)!;

Span?[] spans = spanset.Spanarr();

Expand All @@ -100,16 +100,16 @@ public void EachSpanOfTheSetIsTheSpanTheTextNames()
[TestMethod]
public void SpanTextIsWhatTheSpanHolds()
{
SpanSet spanset = FloatSpanSet.In(SpanSetText)!;
SpanSet spanset = FloatSpanSet.FromText(SpanSetText)!;

Assert.AreEqual("[8, 10]", ((FloatSpan)spanset.StartSpan()!).Out(15));
Assert.AreEqual("[11, 12]", ((FloatSpan)spanset.EndSpan()!).Out(15));
Assert.AreEqual("[8, 10]", ((FloatSpan)spanset.StartSpan()!).AsText(15));
Assert.AreEqual("[11, 12]", ((FloatSpan)spanset.EndSpan()!).AsText(15));
}

[TestMethod]
public void TimeDomainOfTheSequenceIsATstzSpanSet()
{
Temporal temp = TFloat.In(Sequence)!;
Temporal temp = TFloat.FromText(Sequence)!;

SpanSet time = temp.Time()!;

Expand All @@ -132,7 +132,7 @@ public void MakingAnInstantFromAValueAndAMomentReadsBack()
public void MalformedTextRaisesTheMeosError()
{
MEOSException raised = Assert.ThrowsException<MEOSTextInputException>(
() => TFloat.In("e" + Instant));
() => TFloat.FromText("e" + Instant));

StringAssert.Contains(raised.Message, "e25.0");
}
Expand Down
6 changes: 3 additions & 3 deletions MEOS.NET.Tests/MultipleAnswerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MultipleAnswerTests : MeosTest
[TestMethod]
public void SplittingByTimeAnswersThePiecesAndTheirBins()
{
Temporal trip = TFloat.In(
Temporal trip = TFloat.FromText(
"[1@2024-12-06, 2@2024-12-07, 3@2024-12-08]")!;

(Temporal?[] pieces, DateTime[] bins) = trip.TimeSplit(
Expand All @@ -35,7 +35,7 @@ public void SplittingByTimeAnswersThePiecesAndTheirBins()
[TestMethod]
public void SplittingBySpaceAnswersThePiecesAndTheirBins()
{
Temporal trip = TGeomPoint.In(Trip)!;
Temporal trip = TGeomPoint.FromText(Trip)!;
IntPtr origin = Meos.GeomIn("POINT(0 0)", -1);

(IntPtr[] fragments, IntPtr[] bins) = Meos.TgeoSpaceSplit(
Expand All @@ -55,7 +55,7 @@ public void SplittingBySpaceAnswersThePiecesAndTheirBins()
[TestMethod]
public void EachAnswersTheKeysAndTheirValues()
{
Jsonb jb = Jsonb.In("{\"a\": 1, \"b\": \"two\"}")!;
Jsonb jb = Jsonb.FromText("{\"a\": 1, \"b\": \"two\"}")!;

(IntPtr[] keys, IntPtr[] values) = Meos.JsonbEach(jb.Ptr);

Expand Down
Loading
Loading