• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 16517130645

25 Jul 2025 08:07AM UTC coverage: 75.158% (-0.02%) from 75.178%
16517130645

Pull #721

github

web-flow
Merge 60d3e6093 into aea407c1e
Pull Request #721: SVG paper units

6054 of 8854 branches covered (68.38%)

Branch coverage included in aggregate %.

92 of 108 new or added lines in 6 files covered. (85.19%)

14 existing lines in 2 files now uncovered.

24000 of 31134 relevant lines covered (77.09%)

78692.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.0
/src/ACadSharp/IO/SVG/SvgConverter.cs
1
using ACadSharp.Objects;
2
using ACadSharp.Types.Units;
3
using CSMath;
4
using System;
5
using System.ComponentModel;
6
using System.Globalization;
7

8
namespace ACadSharp.IO.SVG
9
{
10
        internal static class SvgConverter
11
        {
12
                public static string ToSvg(this double value)
13
                {
×
14
                        return value.ToString(CultureInfo.InvariantCulture);
×
15
                }
×
16

17
                public static string ToSvg(this double value, UnitsType units)
18
                {
2,154✔
19
                        string unitSufix = string.Empty;
2,154✔
20
                        switch (units)
2,154!
21
                        {
22
                                case UnitsType.Centimeters:
NEW
23
                                        unitSufix = "cm";
×
NEW
24
                                        break;
×
25
                                case UnitsType.Millimeters:
26
                                        unitSufix = "mm";
68✔
27
                                        break;
68✔
28
                                case UnitsType.Inches:
29
                                        unitSufix = "in";
6✔
30
                                        break;
6✔
31
                        }
32

33
                        return $"{value.ToString(CultureInfo.InvariantCulture)}{unitSufix}";
2,154✔
34
                }
2,154✔
35

36
                public static string ToSvg<T>(this T vector)
37
                        where T : IVector
NEW
38
                {
×
NEW
39
                        return $"{vector[0].ToSvg()},{vector[1].ToSvg()}";
×
NEW
40
                }
×
41

42
                public static string ToSvg<T>(this T vector, UnitsType units)
43
                        where T : IVector
44
                {
1,052✔
45
                        return $"{vector[0].ToSvg(units)},{vector[1].ToSvg(units)}";
1,052✔
46
                }
1,052✔
47

48
                public static double ToPixelSize(this double value, UnitsType units)
49
                {
93✔
50
                        switch (units)
93!
51
                        {
52
                                case UnitsType.Inches:
53
                                        return value * 96;
9✔
54
                                case UnitsType.Millimeters:
55
                                        return value * 96 / 25.4;
72✔
56
                                case UnitsType.Unitless:
57
                                        return value;
12✔
58
                                default:
NEW
59
                                        throw new InvalidEnumArgumentException(nameof(units), (int)units, units.GetType());
×
60
                        }
61
                }
93✔
62

63
                public static T ToPixelSize<T>(this T value, UnitsType units)
64
                        where T : IVector
65
                {
31✔
66
                        for (int i = 0; i < value.Dimension; i++)
248✔
67
                        {
93✔
68
                                value[i] = ToPixelSize(value[i], units);
93!
69
                        }
93✔
70

71
                        return value;
31✔
72
                }
31✔
73
        }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc