mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PTRun][UnitConverter]Support negative values (#30776)
This commit is contained in:
@@ -19,6 +19,12 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
[DataRow(new string[] { "1'5\"" }, new string[] { "1", "'", "5", "\"" })]
|
||||
[DataRow(new string[] { "5\"" }, new string[] { "5", "\"" })]
|
||||
[DataRow(new string[] { "1'5" }, new string[] { "1", "'", "5" })]
|
||||
[DataRow(new string[] { "-1,5'" }, new string[] { "-1,5", "'" })]
|
||||
[DataRow(new string[] { "-1.5'" }, new string[] { "-1.5", "'" })]
|
||||
[DataRow(new string[] { "-1'" }, new string[] { "-1", "'" })]
|
||||
[DataRow(new string[] { "-1'5\"" }, new string[] { "-1", "'", "5", "\"" })]
|
||||
[DataRow(new string[] { "-5\"" }, new string[] { "-5", "\"" })]
|
||||
[DataRow(new string[] { "-1'5" }, new string[] { "-1", "'", "5" })]
|
||||
public void RegexSplitsInput(string[] input, string[] expectedResult)
|
||||
{
|
||||
string[] shortsplit = InputInterpreter.RegexSplitter(input);
|
||||
@@ -27,6 +33,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(new string[] { "1cm", "to", "mm" }, new string[] { "1", "cm", "to", "mm" })]
|
||||
[DataRow(new string[] { "-1cm", "to", "mm" }, new string[] { "-1", "cm", "to", "mm" })]
|
||||
public void InsertsSpaces(string[] input, string[] expectedResult)
|
||||
{
|
||||
InputInterpreter.InputSpaceInserter(ref input);
|
||||
@@ -38,6 +45,10 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
[DataRow(new string[] { "1\"", "in", "cm" }, new string[] { "1", "inch", "in", "cm" })]
|
||||
[DataRow(new string[] { "1'6", "in", "cm" }, new string[] { "1.5", "foot", "in", "cm" })]
|
||||
[DataRow(new string[] { "1'6\"", "in", "cm" }, new string[] { "1.5", "foot", "in", "cm" })]
|
||||
[DataRow(new string[] { "-1'", "in", "cm" }, new string[] { "-1", "foot", "in", "cm" })]
|
||||
[DataRow(new string[] { "-1\"", "in", "cm" }, new string[] { "-1", "inch", "in", "cm" })]
|
||||
[DataRow(new string[] { "-1'6", "in", "cm" }, new string[] { "-1.5", "foot", "in", "cm" })]
|
||||
[DataRow(new string[] { "-1'6\"", "in", "cm" }, new string[] { "-1.5", "foot", "in", "cm" })]
|
||||
public void HandlesShorthandFeetInchNotation(string[] input, string[] expectedResult)
|
||||
{
|
||||
InputInterpreter.ShorthandFeetInchHandler(ref input, CultureInfo.InvariantCulture);
|
||||
@@ -69,6 +80,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
[DataTestMethod]
|
||||
[DataRow("a f in c")]
|
||||
[DataRow("12 f in")]
|
||||
[DataRow("1-2 f in c")]
|
||||
[DataRow("12- f in c")]
|
||||
public void ParseInvalidQueries(string queryString)
|
||||
{
|
||||
Query query = new Query(queryString);
|
||||
@@ -79,6 +92,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
[DataTestMethod]
|
||||
[DataRow("12 f in c", 12)]
|
||||
[DataRow("10m to cm", 10)]
|
||||
[DataRow("-12 f in c", -12)]
|
||||
[DataRow("-10m to cm", -10)]
|
||||
public void ParseValidQueries(string queryString, double result)
|
||||
{
|
||||
Query query = new Query(queryString);
|
||||
|
||||
Reference in New Issue
Block a user