Files
RobustToolbox/Robust.Shared.Tests/Utility/CommandParsing_Test.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

38 lines
1.3 KiB
C#

using NUnit.Framework;
using Robust.Shared.Utility;
namespace Robust.Shared.Tests.Utility
{
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
[TestOf(typeof(CommandParsing))]
internal sealed class CommandParsing_Test
{
[TestCase("foo bar", new[] {"foo", "bar"})]
[TestCase("foo bar", new[] {"foo", "bar"})]
[TestCase("foo \"bar baz\"", new[] {"foo", "bar baz"})]
[TestCase("foo \"bar baz\"", new[] {"foo", "bar baz"})]
[TestCase("foo bar baz", new[] {"foo", "bar", "baz"})]
[TestCase(@"foo \""bar\""", new[] {"foo", "\"bar\""})]
[TestCase(@"foo \""b\ar\""", new[] {"foo", "\"bar\""})]
[TestCase("", new string[0])]
public void TestParse(string command, string[] expected)
{
var list = new List<string>();
CommandParsing.ParseArguments(command, list);
Assert.That(list, Is.EqualTo(expected));
}
[TestCase("foo", "foo")]
[TestCase(@"f\oo", @"f\\oo")]
[TestCase(@"f""oo", @"f\""oo")]
public void TestEscape(string source, string expected)
{
var escaped = CommandParsing.Escape(source);
Assert.That(escaped, Is.EqualTo(expected));
}
}
}