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

MeltyPlayer / MeltyTool / 17993985084

25 Sep 2025 01:17AM UTC coverage: 39.931%. Remained the same
17993985084

push

github

MeltyPlayer
Used concrete types throughout solution.

5826 of 16491 branches covered (35.33%)

Branch coverage included in aggregate %.

44 of 85 new or added lines in 38 files covered. (51.76%)

1 existing line in 1 file now uncovered.

24549 of 59577 relevant lines covered (41.21%)

71883.78 hits per line

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

56.96
/FinModelUtility/Fin/Fin/src/util/strings/StringExtensions.cs
1
using System;
2
using System.Text;
3
using System.Text.RegularExpressions;
4

5
using fin.util.asserts;
6

7
namespace fin.util.strings;
8

9
public static class StringExtensions {
10
  public static string Reverse(this string str) {
470✔
11
    var sb = new StringBuilder();
470✔
12
    for (var i = str.Length - 1; i >= 0; --i) {
6,661✔
13
      sb.Append(str[i]);
1,907✔
14
    }
1,907✔
15

16
    return sb.ToString();
470✔
17
  }
470✔
18

19
  public static bool TryRemoveStart(
20
      this string str,
21
      string start,
22
      out string trimmed) {
18✔
23
    if (str.StartsWith(start)) {
36!
24
      trimmed = str[start.Length..];
18✔
25
      return true;
18✔
26
    }
27

NEW
28
    trimmed = null;
×
29
    return false;
×
30
  }
18✔
31

32
  public static string AssertRemoveStart(this string str, string start) {
18✔
33
    Asserts.True(str.TryRemoveStart(start, out var trimmed));
18✔
34
    return trimmed;
18✔
35
  }
18✔
36

37
  public static bool TryRemoveEnd(
38
      this string str,
39
      string end,
40
      out string trimmed) {
16✔
41
    if (str.EndsWith(end)) {
22✔
42
      trimmed = str[..^end.Length];
6✔
43
      return true;
6✔
44
    }
45

46
    trimmed = null;
10✔
47
    return false;
10✔
48
  }
16✔
49

50
  public static string ReplaceFirst(this string str,
51
                                    char target,
52
                                    char replacement) {
×
53
    var index = str.IndexOf(target);
×
54
    if (index < 0) {
×
55
      return str;
×
56
    }
57

58
    var sb = new StringBuilder(str.Length);
×
59
    sb.Append(str[..index]);
×
60
    sb.Append(replacement);
×
61
    sb.Append(str[(index + 1)..]);
×
62
    return sb.ToString();
×
63
  }
×
64

65
  public static (string, string) SplitBeforeAndAfterFirst(
66
      this string text,
67
      char separator) {
×
68
    var index = text.IndexOf(separator);
×
69
    Asserts.True(index >= 0);
×
70
    return (text[..index], text[(index + 1)..]);
×
71
  }
×
72

73
  public static string[] SplitNewlines(this string text)
74
    => Regex.Split(text, "\r\n|\r|\n");
5✔
75

76
  public static string SubstringUpTo(this string str, char c) {
×
77
    var indexTo = str.IndexOf(c);
×
78
    return indexTo >= 0 ? str[..indexTo] : str;
×
79
  }
×
80

81
  public static ReadOnlySpan<char> SubstringUpTo(
82
      this ReadOnlySpan<char> str,
83
      char c) {
670✔
84
    var indexTo = str.IndexOf(c);
670✔
85
    return indexTo >= 0 ? str[..indexTo] : str;
670✔
86
  }
670✔
87

88
  public static ReadOnlySpan<char> SubstringUpTo(
89
      this ReadOnlySpan<char> str,
90
      ReadOnlySpan<char> s) {
×
91
    var indexTo = str.IndexOf(s);
×
92
    return indexTo >= 0 ? str[..indexTo] : str;
×
93
  }
×
94

95

96
  public static string SubstringUpTo(this string str, string substr) {
625✔
97
    var indexTo = str.IndexOf(substr);
625✔
98
    return indexTo >= 0 ? str[..indexTo] : str;
625!
99
  }
625✔
100

101
  public static string SubstringAfter(this string str, string substr) {
607✔
102
    var indexTo = str.IndexOf(substr);
607✔
103
    return indexTo >= 0 ? str[(indexTo + substr.Length)..] : str;
607!
104
  }
607✔
105
}
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