forked from space-wizards/RobustToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically fetch names and descs from loc.
- Loading branch information
Showing
6 changed files
with
159 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Robust.Shared.Utility | ||
{ | ||
public static class CaseConversion | ||
{ | ||
private static readonly Regex PascalToKebabRegex = | ||
new Regex("(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])", RegexOptions.Compiled); | ||
|
||
public static string PascalToKebab(string str) | ||
{ | ||
if (string.IsNullOrWhiteSpace(str)) | ||
return str; | ||
|
||
return PascalToKebabRegex.Replace(str, "-$1").Trim().ToLower(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using NUnit.Framework; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Robust.UnitTesting.Shared.Utility | ||
{ | ||
[Parallelizable(ParallelScope.All)] | ||
[TestFixture] | ||
[TestOf(typeof(CaseConversion))] | ||
public sealed class CaseConversionTest | ||
{ | ||
[Test] | ||
[TestCase("FooBar", ExpectedResult = "foo-bar")] | ||
[TestCase("Foo", ExpectedResult = "foo")] | ||
[TestCase("FooBarBaz", ExpectedResult = "foo-bar-baz")] | ||
[TestCase("AssistantPDA", ExpectedResult = "assistant-pda")] // incorrect abbreviations | ||
[TestCase("AssistantPda", ExpectedResult = "assistant-pda")] // correct abbreviations | ||
[TestCase("FileIO", ExpectedResult = "file-io")] | ||
public string PascalToKebab(string input) | ||
{ | ||
return CaseConversion.PascalToKebab(input); | ||
} | ||
} | ||
} |