mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-04 11:07:12 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.UnitTesting.Shared.Utility
|
|
{
|
|
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
|
|
[TestFixture]
|
|
[TestOf(typeof(CommandParsing))]
|
|
public 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));
|
|
}
|
|
}
|
|
}
|