Исходный код СУБД 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
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using Xunit;
using System.Linq;
 
public abstract class BaseIncreaseLinesTests : PlDotNetTest
{
    protected abstract string FunctionBody { get; }
 
    protected abstract LanguageType Language { get; }
 
    public BaseIncreaseLinesTests()
    {
        FunctionInfo = new SqlFunctionInfo { Name = "IncreaseLines", Arguments = new List<FunctionArgument> { new FunctionArgument("values_array", "LINE[]") }, ReturnType = "LINE[]", Body = FunctionBody, Language = Language, IsStrict = true, CastFunctionAs = "TEXT", };
    }
 
    public static object[][] TestCases()
    {
        return new object[][] { new object[] { "c#-line-1array", "IncreaseLines1", "ARRAY[LINE '{-4.5,5.75,-7.25}', LINE '{-46.5,32.75,-54.5}', null::LINE, LINE '{-1.5,2.75,-3.25}']", "= CAST(ARRAY[LINE '{-3.5,6.75,-6.25}', LINE '{-45.5,33.75,-53.5}', null::LINE, LINE '{-0.5,3.75,-2.25}'] AS TEXT)" }, };
    }
 
    [Theory]
    [MemberData(nameof(TestCases))]
    public void TestIncreaseLines(string featureName, string testName, string input, string expectedResult)
    {
        RunGenericTest(featureName, testName, input, expectedResult);
    }
}
 
[Trait("Language", "CSharp")]
[Trait("Category", "Geometric")]
public class IncreaseLinesTestsCSharp : BaseIncreaseLinesTests
{
    protected override string FunctionBody => @"
Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
ArrayManipulation.FlatArray(values_array, ref flatten_values);
for(int i = 0; i < flatten_values.Length; i++)
{
    if (flatten_values.GetValue(i) == null)
        continue;
 
    NpgsqlLine orig_value = (NpgsqlLine)flatten_values.GetValue(i);
    NpgsqlLine new_value = new NpgsqlLine(orig_value.A + 1, orig_value.B + 1, orig_value.C + 1);
 
    flatten_values.SetValue((NpgsqlLine)new_value, i);
}
return flatten_values;
    ";
    protected override LanguageType Language => LanguageType.PlcSharp;
}