Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-04-30 9f2ef60949ced4fab4d077a7e1c6d913f3620c9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using Xunit;
using System.Linq;
 
public abstract class BaseUpdateArrayPointIndexTests : PlDotNetTest
{
    protected abstract string FunctionBody { get; }
 
    protected abstract LanguageType Language { get; }
 
    public BaseUpdateArrayPointIndexTests()
    {
        FunctionInfo = new SqlFunctionInfo { Name = "UpdateArrayPointIndex", Arguments = new List<FunctionArgument> { new FunctionArgument("values_array", "point[]"), new FunctionArgument("desired", "point"), new FunctionArgument("index", "integer[]") }, ReturnType = "point[]", Body = FunctionBody, Language = Language, IsStrict = true, CastFunctionAs = "TEXT", };
    }
 
    public static object[][] TestCases()
    {
        return new object[][] { new object[] { "c#-point-null-1array", "updateArrayPointIndex1", "ARRAY[POINT(10.0,20.0), POINT(30.0,55.0), null::point, POINT(40.5,21.3)], POINT(31.43, 32.44), ARRAY[2]", "= CAST(ARRAY[POINT(10.0,20.0), POINT(30.0,55.0), POINT(31.43, 32.44), POINT(40.5,21.3)] AS TEXT)" }, new object[] { "c#-point-null-2array-arraynull", "updateArrayPointIndex2", "ARRAY[[null::point, null::point], [null::point, POINT(40.5,21.3)]], POINT(31.43, 32.44), ARRAY[1,0]", "= CAST(ARRAY[[null::point, null::point], [POINT(31.43, 32.44), POINT(40.5,21.3)]] AS TEXT)" }, };
    }
 
    [Theory]
    [MemberData(nameof(TestCases))]
    public void TestUpdateArrayPointIndex(string featureName, string testName, string input, string expectedResult)
    {
        RunGenericTest(featureName, testName, input, expectedResult);
    }
}
 
[Trait("Language", "CSharp")]
[Trait("Category", "Geometric")]
public class UpdateArrayPointIndexTestsCSharp : BaseUpdateArrayPointIndexTests
{
    protected override string FunctionBody => @"
int[] arrayInteger = index.Cast<int>().ToArray();
values_array.SetValue(desired, arrayInteger);
return values_array;
    ";
    protected override LanguageType Language => LanguageType.PlcSharp;
}