mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
Merge branch 'master' into lego/hb_2939_20201109110559091
This commit is contained in:
@@ -13,44 +13,7 @@ namespace ColorPicker.Helpers
|
||||
internal static class ColorHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> color to a HSL color (hue, saturation, lightness)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and lightness [0..1] values of the converted color</returns>
|
||||
internal static (double hue, double saturation, double lightness) ConvertToHSLColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
var lightness = (max + min) / 2d;
|
||||
|
||||
if (lightness == 0d || min == max)
|
||||
{
|
||||
return (color.GetHue(), 0d, lightness);
|
||||
}
|
||||
else if (lightness > 0d && lightness <= 0.5d)
|
||||
{
|
||||
return (color.GetHue(), (max - min) / (max + min), lightness);
|
||||
}
|
||||
|
||||
return (color.GetHue(), (max - min) / (2d - (max + min)), lightness);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> color to a HSV color (hue, saturation, value)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and value [0..1] of the converted color</returns>
|
||||
internal static (double hue, double saturation, double value) ConvertToHSVColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
return (color.GetHue(), max == 0d ? 0d : (max - min) / max, max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> color to a CYMK color (cyan, magenta, yellow, black key)
|
||||
/// Convert a given <see cref="Color"/> to a CYMK color (cyan, magenta, yellow, black key)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The cyan[0..1], magenta[0..1], yellow[0..1] and black key[0..1] of the converted color</returns>
|
||||
@@ -80,5 +43,135 @@ namespace ColorPicker.Helpers
|
||||
|
||||
return (cyan, magenta, yellow, blackKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a HSB color (hue, saturation, brightness)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and brightness [0..1] of the converted color</returns>
|
||||
internal static (double hue, double saturation, double brightness) ConvertToHSBColor(Color color)
|
||||
=> (color.GetHue(), color.GetSaturation(), color.GetBrightness());
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a HSI color (hue, saturation, intensity)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and intensity [0..1] of the converted color</returns>
|
||||
internal static (double hue, double saturation, double intensity) ConvertToHSIColor(Color color)
|
||||
{
|
||||
// special case for black
|
||||
if (color.R == 0 && color.G == 0 && color.B == 0)
|
||||
{
|
||||
return (0d, 0d, 0d);
|
||||
}
|
||||
|
||||
var red = color.R / 255d;
|
||||
var green = color.G / 255d;
|
||||
var blue = color.B / 255d;
|
||||
|
||||
var intensity = (red + green + blue) / 3d;
|
||||
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
|
||||
return (color.GetHue(), 1d - (min / intensity), intensity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a HSL color (hue, saturation, lightness)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and lightness [0..1] values of the converted color</returns>
|
||||
internal static (double hue, double saturation, double lightness) ConvertToHSLColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
var lightness = (max + min) / 2d;
|
||||
|
||||
if (lightness == 0d || min == max)
|
||||
{
|
||||
return (color.GetHue(), 0d, lightness);
|
||||
}
|
||||
else if (lightness > 0d && lightness <= 0.5d)
|
||||
{
|
||||
return (color.GetHue(), (max - min) / (max + min), lightness);
|
||||
}
|
||||
|
||||
return (color.GetHue(), (max - min) / (2d - (max + min)), lightness);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a HSV color (hue, saturation, value)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], saturation [0..1] and value [0..1] of the converted color</returns>
|
||||
internal static (double hue, double saturation, double value) ConvertToHSVColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
return (color.GetHue(), max == 0d ? 0d : (max - min) / max, max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a HWB color (hue, whiteness, blackness)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue [0°..360°], whiteness [0..1] and blackness [0..1] of the converted color</returns>
|
||||
internal static (double hue, double whiteness, double blackness) ConvertToHWBColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
return (color.GetHue(), min, 1 - max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a given <see cref="Color"/> to a natural color (hue, whiteness, blackness)
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
||||
/// <returns>The hue, whiteness [0..1] and blackness [0..1] of the converted color</returns>
|
||||
internal static (string hue, double whiteness, double blackness) ConvertToNaturalColor(Color color)
|
||||
{
|
||||
var min = Math.Min(Math.Min(color.R, color.G), color.B) / 255d;
|
||||
var max = Math.Max(Math.Max(color.R, color.G), color.B) / 255d;
|
||||
|
||||
return (GetNaturalColorFromHue(color.GetHue()), min, 1 - max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the natural color for the given hue value
|
||||
/// </summary>
|
||||
/// <param name="hue">The hue value to convert</param>
|
||||
/// <returns>A natural color</returns>
|
||||
private static string GetNaturalColorFromHue(double hue)
|
||||
{
|
||||
if (hue < 60d)
|
||||
{
|
||||
return $"R{Math.Round(hue / 0.6d, 0)}";
|
||||
}
|
||||
|
||||
if (hue < 120d)
|
||||
{
|
||||
return $"Y{Math.Round((hue - 60d) / 0.6d, 0)}";
|
||||
}
|
||||
|
||||
if (hue < 180d)
|
||||
{
|
||||
return $"G{Math.Round((hue - 120d) / 0.6d, 0)}";
|
||||
}
|
||||
|
||||
if (hue < 240d)
|
||||
{
|
||||
return $"C{Math.Round((hue - 180d) / 0.6d, 0)}";
|
||||
}
|
||||
|
||||
if (hue < 300d)
|
||||
{
|
||||
return $"B{Math.Round((hue - 240d) / 0.6d, 0)}";
|
||||
}
|
||||
|
||||
return $"M{Math.Round((hue - 300d) / 0.6d, 0)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
|
||||
namespace ColorPicker.Helpers
|
||||
{
|
||||
@@ -25,14 +25,38 @@ namespace ColorPicker.Helpers
|
||||
{
|
||||
ColorRepresentationType.CMYK => ColorToCYMK(color),
|
||||
ColorRepresentationType.HEX => ColorToHex(color),
|
||||
ColorRepresentationType.HSB => ColorToHSB(color),
|
||||
ColorRepresentationType.HSI => ColorToHSI(color),
|
||||
ColorRepresentationType.HSL => ColorToHSL(color),
|
||||
ColorRepresentationType.HSV => ColorToHSV(color),
|
||||
ColorRepresentationType.HWB => ColorToHWB(color),
|
||||
ColorRepresentationType.NCol => ColorToNCol(color),
|
||||
ColorRepresentationType.RGB => ColorToRGB(color),
|
||||
|
||||
// Fall-back value, when "_userSettings.CopiedColorRepresentation.Value" is incorrect
|
||||
_ => ColorToHex(color),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a CYMK color
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> for the CYMK color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a CYMK color</returns>
|
||||
private static string ColorToCYMK(Color color)
|
||||
{
|
||||
var (cyan, magenta, yellow, blackKey) = ColorHelper.ConvertToCMYKColor(color);
|
||||
|
||||
cyan = Math.Round(cyan * 100);
|
||||
magenta = Math.Round(magenta * 100);
|
||||
yellow = Math.Round(yellow * 100);
|
||||
blackKey = Math.Round(blackKey * 100);
|
||||
|
||||
return $"cmyk({cyan.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {magenta.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {yellow.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {blackKey.ToString(CultureInfo.InvariantCulture)}%)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a hexadecimal <see cref="string"/> representation of a RGB color
|
||||
/// </summary>
|
||||
@@ -44,19 +68,45 @@ namespace ColorPicker.Helpers
|
||||
+ $"{color.B.ToString("X2", CultureInfo.InvariantCulture)}";
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a RGB color
|
||||
/// Return a <see cref="string"/> representation of a HSB color
|
||||
/// </summary>
|
||||
/// <param name="color">The see cref="Color"/> for the RGB color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a RGB color</returns>
|
||||
private static string ColorToRGB(Color color)
|
||||
=> $"rgb({color.R.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {color.G.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {color.B.ToString(CultureInfo.InvariantCulture)})";
|
||||
/// <param name="color">The <see cref="Color"/> for the HSB color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HSB color</returns>
|
||||
private static string ColorToHSB(Color color)
|
||||
{
|
||||
var (hue, saturation, brightness) = ColorHelper.ConvertToHSBColor(color);
|
||||
|
||||
hue = Math.Round(hue);
|
||||
saturation = Math.Round(saturation * 100);
|
||||
brightness = Math.Round(brightness * 100);
|
||||
|
||||
return $"hsb({hue.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {saturation.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {brightness.ToString(CultureInfo.InvariantCulture)}%)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a HSI color
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> for the HSI color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HSI color</returns>
|
||||
private static string ColorToHSI(Color color)
|
||||
{
|
||||
var (hue, saturation, intensity) = ColorHelper.ConvertToHSIColor(color);
|
||||
|
||||
hue = Math.Round(hue);
|
||||
saturation = Math.Round(saturation * 100);
|
||||
intensity = Math.Round(intensity * 100);
|
||||
|
||||
return $"hsi({hue.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {saturation.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {intensity.ToString(CultureInfo.InvariantCulture)}%)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a HSL color
|
||||
/// </summary>
|
||||
/// <param name="color">The see cref="Color"/> for the HSL color presentation</param>
|
||||
/// <param name="color">The <see cref="Color"/> for the HSL color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HSL color</returns>
|
||||
private static string ColorToHSL(Color color)
|
||||
{
|
||||
@@ -75,7 +125,7 @@ namespace ColorPicker.Helpers
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a HSV color
|
||||
/// </summary>
|
||||
/// <param name="color">The see cref="Color"/> for the HSV color presentation</param>
|
||||
/// <param name="color">The <see cref="Color"/> for the HSV color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HSV color</returns>
|
||||
private static string ColorToHSV(Color color)
|
||||
{
|
||||
@@ -92,24 +142,48 @@ namespace ColorPicker.Helpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a HSV color
|
||||
/// Return a <see cref="string"/> representation of a HWB color
|
||||
/// </summary>
|
||||
/// <param name="color">The see cref="Color"/> for the HSV color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HSV color</returns>
|
||||
private static string ColorToCYMK(Color color)
|
||||
/// <param name="color">The <see cref="Color"/> for the HWB color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a HWB color</returns>
|
||||
private static string ColorToHWB(Color color)
|
||||
{
|
||||
var (cyan, magenta, yellow, blackKey) = ColorHelper.ConvertToCMYKColor(color);
|
||||
var (hue, whiteness, blackness) = ColorHelper.ConvertToHWBColor(color);
|
||||
|
||||
cyan = Math.Round(cyan * 100);
|
||||
magenta = Math.Round(magenta * 100);
|
||||
yellow = Math.Round(yellow * 100);
|
||||
blackKey = Math.Round(blackKey * 100);
|
||||
hue = Math.Round(hue);
|
||||
whiteness = Math.Round(whiteness * 100);
|
||||
blackness = Math.Round(blackness * 100);
|
||||
|
||||
// Using InvariantCulture since this is used for color representation
|
||||
return $"cmyk({cyan.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {magenta.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {yellow.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {blackKey.ToString(CultureInfo.InvariantCulture)}%)";
|
||||
return $"hwb({hue.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {whiteness.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {blackness.ToString(CultureInfo.InvariantCulture)}%)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a natural color
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> for the natural color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a natural color</returns>
|
||||
private static string ColorToNCol(Color color)
|
||||
{
|
||||
var (hue, whiteness, blackness) = ColorHelper.ConvertToNaturalColor(color);
|
||||
|
||||
whiteness = Math.Round(whiteness * 100);
|
||||
blackness = Math.Round(blackness * 100);
|
||||
|
||||
return $"{hue}"
|
||||
+ $", {whiteness.ToString(CultureInfo.InvariantCulture)}%"
|
||||
+ $", {blackness.ToString(CultureInfo.InvariantCulture)}%";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a <see cref="string"/> representation of a RGB color
|
||||
/// </summary>
|
||||
/// <param name="color">The see cref="Color"/> for the RGB color presentation</param>
|
||||
/// <returns>A <see cref="string"/> representation of a RGB color</returns>
|
||||
private static string ColorToRGB(Color color)
|
||||
=> $"rgb({color.R.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {color.G.ToString(CultureInfo.InvariantCulture)}"
|
||||
+ $", {color.B.ToString(CultureInfo.InvariantCulture)})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
|
||||
namespace ColorPicker.Settings
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Threading;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
|
||||
namespace ColorPicker.Settings
|
||||
|
||||
@@ -15,7 +15,6 @@ using ColorPicker.Mouse;
|
||||
using ColorPicker.Settings;
|
||||
using ColorPicker.Telemetry;
|
||||
using ColorPicker.ViewModelContracts;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace ColorPicker.ViewModels
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using ColorPicker.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -41,7 +42,7 @@ namespace UnitTest_ColorPickerUI.Helpers
|
||||
[DataRow(315, 100, 050, 100, 000, 075)] // Red-magenta
|
||||
[DataRow(330, 100, 050, 100, 000, 050)] // Blue-red
|
||||
[DataRow(345, 100, 050, 100, 000, 025)] // Light blue-red
|
||||
public void ColorRGBtoHSL(double hue, double saturation, double lightness, int red, int green, int blue)
|
||||
public void ColorRGBtoHSLTest(double hue, double saturation, double lightness, int red, int green, int blue)
|
||||
{
|
||||
red = Convert.ToInt32(Math.Round(255d / 100d * red)); // [0%..100%] to [0..255]
|
||||
green = Convert.ToInt32(Math.Round(255d / 100d * green)); // [0%..100%] to [0..255]
|
||||
@@ -90,7 +91,7 @@ namespace UnitTest_ColorPickerUI.Helpers
|
||||
[DataRow(315, 100, 100, 100, 000, 075)] // Red-magenta
|
||||
[DataRow(330, 100, 100, 100, 000, 050)] // Blue-red
|
||||
[DataRow(345, 100, 100, 100, 000, 025)] // Light blue-red
|
||||
public void ColorRGBtoHSV(double hue, double saturation, double value, int red, int green, int blue)
|
||||
public void ColorRGBtoHSVTest(double hue, double saturation, double value, int red, int green, int blue)
|
||||
{
|
||||
red = Convert.ToInt32(Math.Round(255d / 100d * red)); // [0%..100%] to [0..255]
|
||||
green = Convert.ToInt32(Math.Round(255d / 100d * green)); // [0%..100%] to [0..255]
|
||||
@@ -138,7 +139,7 @@ namespace UnitTest_ColorPickerUI.Helpers
|
||||
[DataRow(000, 100, 025, 000, 255, 000, 192)] // Red-magenta
|
||||
[DataRow(000, 100, 050, 000, 255, 000, 128)] // Blue-red
|
||||
[DataRow(000, 100, 075, 000, 255, 000, 064)] // Light blue-red
|
||||
public void ColorRGBtoCMYK(int cyan, int magenta, int yellow, int blackKey, int red, int green, int blue)
|
||||
public void ColorRGBtoCMYKTest(int cyan, int magenta, int yellow, int blackKey, int red, int green, int blue)
|
||||
{
|
||||
var color = Color.FromArgb(255, red, green, blue);
|
||||
var result = ColorHelper.ConvertToCMYKColor(color);
|
||||
@@ -156,8 +157,130 @@ namespace UnitTest_ColorPickerUI.Helpers
|
||||
Assert.AreEqual(result.blackKey * 100d, blackKey, 0.5d);
|
||||
}
|
||||
|
||||
// values taken from https://en.wikipedia.org/wiki/HSL_and_HSV#Examples
|
||||
[TestMethod]
|
||||
public void ColorRGBtoCMYKZeroDiv()
|
||||
[DataRow("FFFFFF", 000.0, 000.0, 100.0)] // white
|
||||
[DataRow("808080", 000.0, 000.0, 050.0)] // gray
|
||||
[DataRow("000000", 000.0, 000.0, 000.0)] // black
|
||||
[DataRow("FF0000", 000.0, 100.0, 033.3)] // red
|
||||
[DataRow("BFBF00", 060.0, 100.0, 050.0)] // yellow
|
||||
[DataRow("008000", 120.0, 100.0, 016.7)] // green
|
||||
[DataRow("80FFFF", 180.0, 040.0, 083.3)] // cyan
|
||||
[DataRow("8080FF", 240.0, 025.0, 066.7)] // blue
|
||||
[DataRow("BF40BF", 300.0, 057.1, 058.3)] // magenta
|
||||
[DataRow("A0A424", 061.8, 069.9, 047.1)]
|
||||
[DataRow("411BEA", 251.1, 075.6, 042.6)]
|
||||
[DataRow("1EAC41", 134.9, 066.7, 034.9)]
|
||||
[DataRow("F0C80E", 049.5, 091.1, 059.3)]
|
||||
[DataRow("B430E5", 283.7, 068.6, 059.6)]
|
||||
[DataRow("ED7651", 014.3, 044.6, 057.0)]
|
||||
[DataRow("FEF888", 056.9, 036.3, 083.5)]
|
||||
[DataRow("19CB97", 162.4, 080.0, 049.5)]
|
||||
[DataRow("362698", 248.3, 053.3, 031.9)]
|
||||
[DataRow("7E7EB8", 240.5, 013.5, 057.0)]
|
||||
public void ColorRGBtoHSITest(string hexValue, double hue, double saturation, double intensity)
|
||||
{
|
||||
var red = int.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber);
|
||||
var green = int.Parse(hexValue.Substring(2, 2), NumberStyles.HexNumber);
|
||||
var blue = int.Parse(hexValue.Substring(4, 2), NumberStyles.HexNumber);
|
||||
|
||||
var color = Color.FromArgb(255, red, green, blue);
|
||||
var result = ColorHelper.ConvertToHSIColor(color);
|
||||
|
||||
// hue[0<>..360<EFBFBD>]
|
||||
Assert.AreEqual(result.hue, hue, 0.5d);
|
||||
|
||||
// saturation[0..1]
|
||||
Assert.AreEqual(result.saturation * 100d, saturation, 0.5d);
|
||||
|
||||
// intensity[0..1]
|
||||
Assert.AreEqual(result.intensity * 100d, intensity, 0.5d);
|
||||
}
|
||||
|
||||
// values taken from https://en.wikipedia.org/wiki/HSL_and_HSV#Examples
|
||||
// and manual convert via https://colorconv.com/hwb
|
||||
[TestMethod]
|
||||
[DataRow("FFFFFF", 000, 100, 000)] // white
|
||||
[DataRow("808080", 000, 050, 050)] // gray
|
||||
[DataRow("000000", 000, 000, 100)] // black
|
||||
[DataRow("FF0000", 000, 000, 000)] // red
|
||||
[DataRow("BFBF00", 060, 000, 025)] // yellow
|
||||
[DataRow("008000", 120, 000, 050)] // green
|
||||
[DataRow("80FFFF", 180, 050, 000)] // cyan
|
||||
[DataRow("8080FF", 240, 050, 000)] // blue
|
||||
[DataRow("BF40BF", 300, 025, 025)] // magenta
|
||||
[DataRow("A0A424", 062, 014, 036)]
|
||||
[DataRow("411BEA", 251, 011, 008)]
|
||||
[DataRow("1EAC41", 135, 012, 033)]
|
||||
[DataRow("F0C80E", 049, 005, 006)]
|
||||
[DataRow("B430E5", 284, 019, 010)]
|
||||
[DataRow("ED7651", 014, 032, 007)]
|
||||
[DataRow("FEF888", 057, 053, 000)]
|
||||
[DataRow("19CB97", 162, 010, 020)]
|
||||
[DataRow("362698", 248, 015, 040)]
|
||||
[DataRow("7E7EB8", 240, 049, 028)]
|
||||
public void ColorRGBtoHWBTest(string hexValue, double hue, double whiteness, double blackness)
|
||||
{
|
||||
var red = int.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber);
|
||||
var green = int.Parse(hexValue.Substring(2, 2), NumberStyles.HexNumber);
|
||||
var blue = int.Parse(hexValue.Substring(4, 2), NumberStyles.HexNumber);
|
||||
|
||||
var color = Color.FromArgb(255, red, green, blue);
|
||||
var result = ColorHelper.ConvertToHWBColor(color);
|
||||
|
||||
// hue[0<>..360<EFBFBD>]
|
||||
Assert.AreEqual(result.hue, hue, 0.5d);
|
||||
|
||||
// whiteness[0..1]
|
||||
Assert.AreEqual(result.whiteness * 100d, whiteness, 0.5d);
|
||||
|
||||
// blackness[0..1]
|
||||
Assert.AreEqual(result.blackness * 100d, blackness, 0.5d);
|
||||
}
|
||||
|
||||
// values taken from https://en.wikipedia.org/wiki/HSL_and_HSV#Examples
|
||||
// and manual convert via https://colorconv.com/hwb
|
||||
[TestMethod]
|
||||
[DataRow("FFFFFF", "R0", 100, 000)] // white
|
||||
[DataRow("808080", "R0", 050, 050)] // gray
|
||||
[DataRow("000000", "R0", 000, 100)] // black
|
||||
[DataRow("FF0000", "R0", 000, 000)] // red
|
||||
[DataRow("BFBF00", "Y0", 000, 025)] // yellow
|
||||
[DataRow("008000", "G0", 000, 050)] // green
|
||||
[DataRow("80FFFF", "C0", 050, 000)] // cyan
|
||||
[DataRow("8080FF", "B0", 050, 000)] // blue
|
||||
[DataRow("BF40BF", "M0", 025, 025)] // magenta
|
||||
[DataRow("A0A424", "Y3", 014, 036)]
|
||||
[DataRow("411BEA", "B18", 011, 008)]
|
||||
[DataRow("1EAC41", "G25", 012, 033)]
|
||||
[DataRow("F0C80E", "R82", 005, 006)]
|
||||
[DataRow("B430E5", "B73", 019, 010)]
|
||||
[DataRow("ED7651", "R24", 032, 007)]
|
||||
[DataRow("FEF888", "R95", 053, 000)]
|
||||
[DataRow("19CB97", "G71", 010, 020)]
|
||||
[DataRow("362698", "B14", 015, 040)]
|
||||
[DataRow("7E7EB8", "B0", 049, 028)]
|
||||
public void ColorRGBtoNColTest(string hexValue, string hue, double whiteness, double blackness)
|
||||
{
|
||||
var red = int.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber);
|
||||
var green = int.Parse(hexValue.Substring(2, 2), NumberStyles.HexNumber);
|
||||
var blue = int.Parse(hexValue.Substring(4, 2), NumberStyles.HexNumber);
|
||||
|
||||
var color = Color.FromArgb(255, red, green, blue);
|
||||
var result = ColorHelper.ConvertToNaturalColor(color);
|
||||
|
||||
// hue
|
||||
Assert.AreEqual(result.hue, hue);
|
||||
|
||||
// whiteness[0..1]
|
||||
Assert.AreEqual(result.whiteness * 100d, whiteness, 0.5d);
|
||||
|
||||
// blackness[0..1]
|
||||
Assert.AreEqual(result.blackness * 100d, blackness, 0.5d);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ColorRGBtoCMYKZeroDivTest()
|
||||
{
|
||||
for(var red = 0; red < 256; red++)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using ColorPicker.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Drawing;
|
||||
|
||||
@@ -11,11 +11,15 @@ namespace UnitTest_ColorPickerUI.Helpers
|
||||
[TestMethod]
|
||||
[DataRow(ColorRepresentationType.CMYK, "cmyk(0%, 0%, 0%, 100%)")]
|
||||
[DataRow(ColorRepresentationType.HEX, "#000000")]
|
||||
[DataRow(ColorRepresentationType.NCol, "R0, 0%, 100%")]
|
||||
[DataRow(ColorRepresentationType.HSB, "hsb(0, 0%, 0%)")]
|
||||
[DataRow(ColorRepresentationType.HSI, "hsi(0, 0%, 0%)")]
|
||||
[DataRow(ColorRepresentationType.HSL, "hsl(0, 0%, 0%)")]
|
||||
[DataRow(ColorRepresentationType.HSV, "hsv(0, 0%, 0%)")]
|
||||
[DataRow(ColorRepresentationType.HWB, "hwb(0, 0%, 100%)")]
|
||||
[DataRow(ColorRepresentationType.RGB, "rgb(0, 0, 0)")]
|
||||
|
||||
public void ColorRGBtoCMYKZeroDiv(ColorRepresentationType type, string expected)
|
||||
public void GetStringRepresentationTest(ColorRepresentationType type, string expected)
|
||||
{
|
||||
var result = ColorRepresentationHelper.GetStringRepresentation(Color.Black, type);
|
||||
Assert.AreEqual(result, expected);
|
||||
|
||||
@@ -91,6 +91,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Layout_Delete_Button" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Delete custom layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Benutzerdefiniertes Layout löschen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Table_Layout" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Custom table layout creator]]></Val>
|
||||
@@ -136,6 +145,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Grid_Layout_Editor" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Grid layout editor]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Rasterlayout-Editor]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Name" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Name]]></Val>
|
||||
@@ -190,6 +208,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Decrement" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Decrement number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Anzahl von Zonen im Vorlagenlayout verringern]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Increment" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Increment number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Anzahl von Zonen im Vorlagenlayout erhöhen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>
|
||||
@@ -91,6 +91,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Layout_Delete_Button" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Delete custom layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Supprimer la disposition personnalisée]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Table_Layout" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Custom table layout creator]]></Val>
|
||||
@@ -136,6 +145,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Grid_Layout_Editor" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Grid layout editor]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Éditeur de disposition de grille]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Name" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Name]]></Val>
|
||||
@@ -190,6 +208,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Decrement" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Decrement number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Décrémenter le nombre de zones dans la disposition du modèle]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Increment" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Increment number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Incrémenter le nombre de zones dans la disposition du modèle]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>
|
||||
@@ -91,6 +91,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Layout_Delete_Button" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Delete custom layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aangepaste indeling verwijderen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Table_Layout" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Custom table layout creator]]></Val>
|
||||
@@ -136,6 +145,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Grid_Layout_Editor" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Grid layout editor]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Editor voor rasterindeling]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Name" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Name]]></Val>
|
||||
@@ -190,6 +208,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Decrement" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Decrement number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aantal zones in sjabloonindeling verlagen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Increment" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Increment number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aantal zones in sjabloonindeling verhogen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>
|
||||
@@ -91,6 +91,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Layout_Delete_Button" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Delete custom layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Удалить пользовательский макет]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Table_Layout" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Custom table layout creator]]></Val>
|
||||
@@ -136,6 +145,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Grid_Layout_Editor" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Grid layout editor]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Редактор макета сетки]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Name" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Name]]></Val>
|
||||
@@ -190,6 +208,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Decrement" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Decrement number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Уменьшение числа зон в макете шаблона]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Increment" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Increment number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Увеличение числа зон в макете шаблона]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>
|
||||
@@ -91,6 +91,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Layout_Delete_Button" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Delete custom layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[刪除自訂配置]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Custom_Table_Layout" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Custom table layout creator]]></Val>
|
||||
@@ -136,6 +145,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Grid_Layout_Editor" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Grid layout editor]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[方格配置編輯器]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Name" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Name]]></Val>
|
||||
@@ -190,6 +208,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Decrement" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Decrement number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[減少範本配置中的區域數]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Zone_Count_Increment" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Increment number of zones in template layout]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[增加範本配置中的區域數]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>
|
||||
@@ -106,7 +106,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.2.10">
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.3.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SharpZipLib" Version="1.2.0" />
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace PowerLauncher
|
||||
{
|
||||
string path = Log.CurrentLogDirectory;
|
||||
var directory = new DirectoryInfo(path);
|
||||
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
|
||||
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).FirstOrDefault();
|
||||
|
||||
LogFilePathBox.Text = log.FullName;
|
||||
LogFilePathBox.Text = log?.FullName;
|
||||
|
||||
StringBuilder content = new StringBuilder();
|
||||
content.AppendLine(ErrorReporting.RuntimeInfo());
|
||||
|
||||
@@ -120,10 +120,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";deseralization_error_title" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Powertoys Run deserialization error]]></Val>
|
||||
<Val><![CDATA[PowerToys Run deserialization error]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ошибка десериализации Панели PowerToys]]></Val>
|
||||
<Val><![CDATA[Ошибка десериализации Панели PowerToys]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Powertoys Run deserialization error]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@@ -154,7 +157,7 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";reportWindow_file_bug" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";reportWindow_file_bug" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Please file a bug in the]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
@@ -163,7 +166,7 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";reportWindow_github_repo" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";reportWindow_github_repo" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[PowerToys GitHub repository]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace Wox.Plugin.Logger
|
||||
var rule = new LoggingRule("*", LogLevel.Info, target);
|
||||
#endif
|
||||
configuration.LoggingRules.Add(rule);
|
||||
LogManager.Configuration = configuration;
|
||||
target.Dispose();
|
||||
LogManager.Configuration = configuration;
|
||||
}
|
||||
|
||||
private static void LogInternalException(string message, System.Exception e, Type fullClassName, [CallerMemberName] string methodName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.2.10">
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.3.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
|
||||
@@ -146,6 +146,8 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -153,5 +155,7 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.72.0.0\build\boost.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="boost" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -218,6 +218,8 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -225,5 +227,7 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.72.0.0\build\boost.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -144,4 +144,8 @@
|
||||
<data name="Extended_Menu_Info" xml:space="preserve">
|
||||
<value>Only show the PowerRename menu item on the extended context menu (Shift + Right-click).</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="Use_Boost_Lib" xml:space="preserve">
|
||||
<value>Use Boost library (provides extended features but may use different regex syntax).</value>
|
||||
<comment>Boost is a product name, should not be translated</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -234,6 +234,11 @@ public:
|
||||
GET_RESOURCE_STRING(IDS_EXTENDED_MENU_INFO),
|
||||
CSettingsInstance().GetExtendedContextMenuOnly());
|
||||
|
||||
settings.add_bool_toggle(
|
||||
L"bool_use_boost_lib",
|
||||
GET_RESOURCE_STRING(IDS_USE_BOOST_LIB),
|
||||
CSettingsInstance().GetUseBoostLib());
|
||||
|
||||
return settings.serialize_to_buffer(buffer, buffer_size);
|
||||
}
|
||||
|
||||
@@ -252,6 +257,7 @@ public:
|
||||
CSettingsInstance().SetMaxMRUSize(values.get_int_value(L"int_max_mru_size").value());
|
||||
CSettingsInstance().SetShowIconOnMenu(values.get_bool_value(L"bool_show_icon_on_menu").value());
|
||||
CSettingsInstance().SetExtendedContextMenuOnly(values.get_bool_value(L"bool_show_extended_menu").value());
|
||||
CSettingsInstance().SetUseBoostLib(values.get_bool_value(L"bool_use_boost_lib").value());
|
||||
CSettingsInstance().Save();
|
||||
|
||||
Trace::SettingsChanged();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="boost" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -189,6 +189,8 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -196,5 +198,7 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.72.0.0\build\boost.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "pch.h"
|
||||
#include "PowerRenameRegEx.h"
|
||||
#include "Settings.h"
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -177,6 +179,8 @@ CPowerRenameRegEx::CPowerRenameRegEx() :
|
||||
// Init to empty strings
|
||||
SHStrDup(L"", &m_searchTerm);
|
||||
SHStrDup(L"", &m_replaceTerm);
|
||||
|
||||
_useBoostLib = CSettingsInstance().GetUseBoostLib();
|
||||
}
|
||||
|
||||
CPowerRenameRegEx::~CPowerRenameRegEx()
|
||||
@@ -206,14 +210,29 @@ HRESULT CPowerRenameRegEx::Replace(_In_ PCWSTR source, _Outptr_ PWSTR* result)
|
||||
|
||||
if (m_flags & UseRegularExpressions)
|
||||
{
|
||||
std::wregex pattern(m_searchTerm, (!(m_flags & CaseSensitive)) ? regex_constants::icase | regex_constants::ECMAScript : regex_constants::ECMAScript);
|
||||
if (m_flags & MatchAllOccurences)
|
||||
if (_useBoostLib)
|
||||
{
|
||||
res = regex_replace(wstring(source), pattern, replaceTerm);
|
||||
boost::wregex pattern(m_searchTerm, (!(m_flags & CaseSensitive)) ? boost::regex::icase | boost::regex::ECMAScript : boost::regex::ECMAScript);
|
||||
if (m_flags & MatchAllOccurences)
|
||||
{
|
||||
res = boost::regex_replace(wstring(source), pattern, replaceTerm);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = boost::regex_replace(wstring(source), pattern, replaceTerm, boost::regex_constants::format_first_only);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res = regex_replace(wstring(source), pattern, replaceTerm, regex_constants::format_first_only);
|
||||
std::wregex pattern(m_searchTerm, (!(m_flags & CaseSensitive)) ? regex_constants::icase | regex_constants::ECMAScript : regex_constants::ECMAScript);
|
||||
if (m_flags & MatchAllOccurences)
|
||||
{
|
||||
res = regex_replace(wstring(source), pattern, replaceTerm);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = regex_replace(wstring(source), pattern, replaceTerm, regex_constants::format_first_only);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -39,6 +39,7 @@ protected:
|
||||
|
||||
size_t _Find(std::wstring data, std::wstring toSearch, bool caseInsensitive, size_t pos);
|
||||
|
||||
bool _useBoostLib = false;
|
||||
DWORD m_flags = DEFAULT_FLAGS;
|
||||
PWSTR m_searchTerm = nullptr;
|
||||
PWSTR m_replaceTerm = nullptr;
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace
|
||||
const wchar_t c_mruEnabled[] = L"MRUEnabled";
|
||||
const wchar_t c_mruList[] = L"MRUList";
|
||||
const wchar_t c_insertionIdx[] = L"InsertionIdx";
|
||||
const wchar_t c_useBoostLib[] = L"UseBoostLib";
|
||||
|
||||
unsigned int GetRegNumber(const std::wstring& valueName, unsigned int defaultValue)
|
||||
{
|
||||
@@ -414,6 +415,7 @@ void CSettings::Save()
|
||||
jsonData.SetNamedValue(c_maxMRUSize, json::value(settings.maxMRUSize));
|
||||
jsonData.SetNamedValue(c_searchText, json::value(settings.searchText));
|
||||
jsonData.SetNamedValue(c_replaceText, json::value(settings.replaceText));
|
||||
jsonData.SetNamedValue(c_useBoostLib, json::value(settings.useBoostLib));
|
||||
|
||||
json::to_file(jsonFilePath, jsonData);
|
||||
GetSystemTimeAsFileTime(&lastLoadedTime);
|
||||
@@ -457,6 +459,7 @@ void CSettings::MigrateFromRegistry()
|
||||
settings.flags = GetRegNumber(c_flags, 0);
|
||||
settings.searchText = GetRegString(c_searchText, L"");
|
||||
settings.replaceText = GetRegString(c_replaceText, L"");
|
||||
settings.useBoostLib = false; // Never existed in registry, disabled by default.
|
||||
}
|
||||
|
||||
void CSettings::ParseJson()
|
||||
@@ -499,6 +502,10 @@ void CSettings::ParseJson()
|
||||
{
|
||||
settings.replaceText = jsonSettings.GetNamedString(c_replaceText);
|
||||
}
|
||||
if (json::has(jsonSettings, c_useBoostLib, json::JsonValueType::Boolean))
|
||||
{
|
||||
settings.useBoostLib = jsonSettings.GetNamedBoolean(c_useBoostLib);
|
||||
}
|
||||
}
|
||||
catch (const winrt::hresult_error&) { }
|
||||
}
|
||||
|
||||
@@ -51,6 +51,16 @@ public:
|
||||
settings.persistState = persistState;
|
||||
}
|
||||
|
||||
inline bool GetUseBoostLib() const
|
||||
{
|
||||
return settings.useBoostLib;
|
||||
}
|
||||
|
||||
inline void SetUseBoostLib(bool useBoostLib)
|
||||
{
|
||||
settings.useBoostLib = useBoostLib;
|
||||
}
|
||||
|
||||
inline bool GetMRUEnabled() const
|
||||
{
|
||||
return settings.MRUEnabled;
|
||||
@@ -114,6 +124,7 @@ private:
|
||||
bool showIconOnMenu{ true };
|
||||
bool extendedContextMenuOnly{ false }; // Disabled by default.
|
||||
bool persistState{ true };
|
||||
bool useBoostLib{ false }; // Disabled by default.
|
||||
bool MRUEnabled{ true };
|
||||
unsigned int maxMRUSize{ 10 };
|
||||
unsigned int flags{ 0 };
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="boost" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -85,5 +85,6 @@ void Trace::SettingsChanged() noexcept
|
||||
TraceLoggingBoolean(CSettingsInstance().GetPersistState(), "PersistState"),
|
||||
TraceLoggingBoolean(CSettingsInstance().GetMRUEnabled(), "IsMRUEnabled"),
|
||||
TraceLoggingUInt64(CSettingsInstance().GetMaxMRUSize(), "MaxMRUSize"),
|
||||
TraceLoggingBoolean(CSettingsInstance().GetUseBoostLib(), "UseBoostLib"),
|
||||
TraceLoggingUInt64(CSettingsInstance().GetFlags(), "Flags"));
|
||||
}
|
||||
|
||||
@@ -202,6 +202,8 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -209,5 +211,7 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.72.0.0\build\boost.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="boost" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -37,11 +37,20 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";Countslabelrenamingfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u | Renaming: %u]]></Val>
|
||||
<Val><![CDATA[Items Renaming: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ausgewählte Elemente: %u | Umbenennung: %u]]></Val>
|
||||
<Val><![CDATA[Umbenannte Elemente: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelselectedfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ausgewählte Elemente: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -118,12 +127,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Renaming" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Renaming: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Umbenannte Elemente: 0]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Selected" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
<Val><![CDATA[Items Selected: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ausgewählte Elemente: 0 | Umbenennung: 0]]></Val>
|
||||
<Val><![CDATA[Ausgewählte Elemente: 0]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";Countslabelrenamingfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u | Renaming: %u]]></Val>
|
||||
<Val><![CDATA[Items Renaming: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Éléments sélectionnés : %u | Renommage : %u]]></Val>
|
||||
<Val><![CDATA[Renommage des éléments : %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelselectedfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Éléments sélectionnés : %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -118,12 +127,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Renaming" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Renaming: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Renommage des éléments : 0]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Selected" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
<Val><![CDATA[Items Selected: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Éléments sélectionnés : 0 | Renommage : 0]]></Val>
|
||||
<Val><![CDATA[Éléments sélectionnés : 0]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";Countslabelrenamingfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u | Renaming: %u]]></Val>
|
||||
<Val><![CDATA[Items Renaming: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Geselecteerde items: %u | Naam wijzigen: %u]]></Val>
|
||||
<Val><![CDATA[Items waarvoor de naam wordt gewijzigd: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelselectedfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Geselecteerde items: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -118,12 +127,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Renaming" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Renaming: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Items waarvoor de naam wordt gewijzigd: 0]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Selected" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
<Val><![CDATA[Items Selected: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Geselecteerde items: 0 | Naam wijzigen: 0]]></Val>
|
||||
<Val><![CDATA[Geselecteerde items: 0]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";Countslabelrenamingfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u | Renaming: %u]]></Val>
|
||||
<Val><![CDATA[Items Renaming: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Выбрано элементов: %u | Переименовывается: %u]]></Val>
|
||||
<Val><![CDATA[Переименование элементов: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelselectedfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Выбрано элементов: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -118,12 +127,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Renaming" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Renaming: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Переименование элементов: 0]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Selected" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
<Val><![CDATA[Items Selected: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Выбрано элементов: 0 | Переименовывается: 0]]></Val>
|
||||
<Val><![CDATA[Выбрано элементов: 0]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Item ItemId=";Countslabelrenamingfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u | Renaming: %u]]></Val>
|
||||
<Val><![CDATA[Items Renaming: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[選取的項目: %u | 將重新命名: %u]]></Val>
|
||||
<Val><![CDATA[要重新命名的項目數: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Countslabelselectedfmt" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: %u]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[選取的項目數: %u]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -118,12 +127,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Renaming" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Renaming: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[要重新命名的項目數: 0]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Items_Selected" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
<Val><![CDATA[Items Selected: 0]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[選取的項目: 0 | 將重新命名: 0]]></Val>
|
||||
<Val><![CDATA[選取的項目數: 0]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Items Selected: 0 | Renaming: 0]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
@@ -196,6 +196,7 @@
|
||||
<ClCompile Include="MockPowerRenameItem.cpp" />
|
||||
<ClCompile Include="MockPowerRenameManagerEvents.cpp" />
|
||||
<ClCompile Include="MockPowerRenameRegExEvents.cpp" />
|
||||
<ClCompile Include="PowerRenameRegExBoostTests.cpp" />
|
||||
<ClCompile Include="PowerRenameManagerTests.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>
|
||||
@@ -217,6 +218,8 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" />
|
||||
<Import Project="..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets" Condition="Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -224,5 +227,7 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost.1.72.0.0\build\boost.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\boost_regex-vc142.1.72.0.0\build\boost_regex-vc142.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -8,6 +8,7 @@
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="PowerRenameRegExTests.cpp" />
|
||||
<ClCompile Include="TestFileHelper.cpp" />
|
||||
<ClCompile Include="PowerRenameRegExBoostTests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MockPowerRenameItem.h" />
|
||||
|
||||
437
src/modules/powerrename/unittests/PowerRenameRegExBoostTests.cpp
Normal file
437
src/modules/powerrename/unittests/PowerRenameRegExBoostTests.cpp
Normal file
@@ -0,0 +1,437 @@
|
||||
#include "pch.h"
|
||||
#include "CppUnitTest.h"
|
||||
#include "powerrename/lib/Settings.h"
|
||||
#include <PowerRenameInterfaces.h>
|
||||
#include <PowerRenameRegEx.h>
|
||||
#include "MockPowerRenameRegExEvents.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace PowerRenameRegExBoostTests
|
||||
{
|
||||
struct SearchReplaceExpected
|
||||
{
|
||||
PCWSTR search;
|
||||
PCWSTR replace;
|
||||
PCWSTR test;
|
||||
PCWSTR expected;
|
||||
};
|
||||
|
||||
TEST_CLASS(SimpleTests)
|
||||
{
|
||||
public:
|
||||
TEST_CLASS_INITIALIZE(ClassInitialize)
|
||||
{
|
||||
CSettingsInstance().SetUseBoostLib(true);
|
||||
}
|
||||
|
||||
TEST_CLASS_CLEANUP(ClassCleanup)
|
||||
{
|
||||
CSettingsInstance().SetUseBoostLib(false);
|
||||
}
|
||||
|
||||
TEST_METHOD(GeneralReplaceTest)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"foo") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(L"big") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(L"foobar", &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, L"bigbar") == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
|
||||
TEST_METHOD(ReplaceNoMatch)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"notfound") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(L"big") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(L"foobar", &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, L"foobar") == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
|
||||
TEST_METHOD(ReplaceNoSearchOrReplaceTerm)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->Replace(L"foobar", &result) != S_OK);
|
||||
Assert::IsTrue(result == nullptr);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
|
||||
TEST_METHOD(ReplaceNoReplaceTerm)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"foo") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(L"foobar", &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, L"bar") == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
|
||||
TEST_METHOD(ReplaceEmptyStringReplaceTerm)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"foo") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(L"") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(L"foobar", &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, L"bar") == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyDefaultFlags)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = 0;
|
||||
Assert::IsTrue(renameRegEx->GetFlags(&flags) == S_OK);
|
||||
Assert::IsTrue(flags == MatchAllOccurences);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyCaseSensitiveSearch)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = CaseSensitive;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"Foo", L"Foo", L"FooBar", L"FooBar" },
|
||||
{ L"Foo", L"boo", L"FooBar", L"booBar" },
|
||||
{ L"Foo", L"boo", L"foobar", L"foobar" },
|
||||
{ L"123", L"654", L"123456", L"654456" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstOnly)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = 0;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AABBA" },
|
||||
{ L"B", L"BBB", L"ABABAB", L"ABBBABAB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceAll)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AAAAA" },
|
||||
{ L"B", L"BBB", L"ABABAB", L"ABBBABBBABBB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceAllCaseInsensitive)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | CaseSensitive;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AAAAA" },
|
||||
{ L"B", L"BBB", L"ABABAB", L"ABBBABBBABBB" },
|
||||
{ L"b", L"BBB", L"AbABAb", L"ABBBABABBB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstOnlyUseRegEx)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = UseRegularExpressions;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AABBA" },
|
||||
{ L"B", L"BBB", L"ABABAB", L"ABBBABAB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceAllUseRegEx)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | UseRegularExpressions;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AAAAA" },
|
||||
{ L"B", L"BBB", L"ABABAB", L"ABBBABBBABBB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceAllUseRegExCaseSensitive)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | UseRegularExpressions | CaseSensitive;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
{ L"B", L"BB", L"ABA", L"ABBA" },
|
||||
{ L"B", L"A", L"ABBBA", L"AAAAA" },
|
||||
{ L"b", L"BBB", L"AbABAb", L"ABBBABABBB" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyMatchAllWildcardUseRegEx)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | UseRegularExpressions;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
// This differs from the Standard Library: .* has two matches (all and nothing).
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L".*", L"Foo", L"AAAAAA", L"FooFoo" },
|
||||
{ L".+", L"Foo", L"AAAAAA", L"Foo" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyReplaceFirstWildcard(SearchReplaceExpected sreTable[], int tableSize, DWORD flags)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
for (int i = 0; i < tableSize; i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::AreEqual(sreTable[i].expected, result);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstWildCardUseRegex)
|
||||
{
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L".*", L"Foo", L"AAAAAA", L"Foo" },
|
||||
};
|
||||
VerifyReplaceFirstWildcard(sreTable, ARRAYSIZE(sreTable), UseRegularExpressions);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstWildCardUseRegexMatchAllOccurrences)
|
||||
{
|
||||
// This differs from the Standard Library: .* has two matches (all and nothing).
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L".*", L"Foo", L"AAAAAA", L"FooFoo" },
|
||||
{ L".+", L"Foo", L"AAAAAA", L"Foo" },
|
||||
};
|
||||
VerifyReplaceFirstWildcard(sreTable, ARRAYSIZE(sreTable), UseRegularExpressions | MatchAllOccurences);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstWildCardMatchAllOccurrences)
|
||||
{
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L".*", L"Foo", L"AAAAAA", L"AAAAAA" },
|
||||
{ L".*", L"Foo", L".*", L"Foo" },
|
||||
{ L".*", L"Foo", L".*Bar.*", L"FooBarFoo" },
|
||||
};
|
||||
VerifyReplaceFirstWildcard(sreTable, ARRAYSIZE(sreTable), MatchAllOccurences);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyReplaceFirstWildNoFlags)
|
||||
{
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L".*", L"Foo", L"AAAAAA", L"AAAAAA" },
|
||||
{ L".*", L"Foo", L".*", L"Foo" },
|
||||
};
|
||||
VerifyReplaceFirstWildcard(sreTable, ARRAYSIZE(sreTable), 0);
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyHandleCapturingGroups)
|
||||
{
|
||||
// This differs from the Standard Library: Boost does not recognize $123 as $1 and "23".
|
||||
// To use a capturing group followed by numbers as replacement curly braces are needed.
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | UseRegularExpressions | CaseSensitive;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L"(foo)(bar)", L"$1_$002_$223_$001021_$00001", L"foobar", L"foo_$002__$001021_$00001" },
|
||||
{ L"(foo)(bar)", L"$1_$002_${2}23_$001021_$00001", L"foobar", L"foo_$002_bar23_$001021_$00001" },
|
||||
{ L"(foo)(bar)", L"_$1$2_$123$040", L"foobar", L"_foobar_$040" },
|
||||
{ L"(foo)(bar)", L"_$1$2_${1}23$040", L"foobar", L"_foobar_foo23$040" },
|
||||
{ L"(foo)(bar)", L"$$$1", L"foobar", L"$foo" },
|
||||
{ L"(foo)(bar)", L"$$1", L"foobar", L"$1" },
|
||||
{ L"(foo)(bar)", L"$12", L"foobar", L"" },
|
||||
{ L"(foo)(bar)", L"${1}2", L"foobar", L"foo2" },
|
||||
{ L"(foo)(bar)", L"$10", L"foobar", L"" },
|
||||
{ L"(foo)(bar)", L"${1}0", L"foobar", L"foo0" },
|
||||
{ L"(foo)(bar)", L"$01", L"foobar", L"$01" },
|
||||
{ L"(foo)(bar)", L"$$$11", L"foobar", L"$" },
|
||||
{ L"(foo)(bar)", L"$$${1}1", L"foobar", L"$foo1" },
|
||||
{ L"(foo)(bar)", L"$$$$113a", L"foobar", L"$$113a" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyLookbehind)
|
||||
{
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L"(?<=E12).*", L"Foo", L"AAE12BBB", L"AAE12Foo" },
|
||||
{ L"(?<=E12).+", L"Foo", L"AAE12BBB", L"AAE12Foo" },
|
||||
{ L"(?<=E\\d\\d).+", L"Foo", L"AAE12BBB", L"AAE12Foo" },
|
||||
{ L"(?<!E12).*", L"Foo", L"AAE12BBB", L"Foo" },
|
||||
{ L"(?<!E12).+", L"Foo", L"AAE12BBB", L"Foo" },
|
||||
{ L"(?<!E\\d\\d).+", L"Foo", L"AAE12BBB", L"Foo" },
|
||||
};
|
||||
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutFlags(UseRegularExpressions) == S_OK);
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == S_OK);
|
||||
Assert::IsTrue(wcscmp(result, sreTable[i].expected) == 0);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyEventsFire)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
CMockPowerRenameRegExEvents* mockEvents = new CMockPowerRenameRegExEvents();
|
||||
CComPtr<IPowerRenameRegExEvents> regExEvents;
|
||||
Assert::IsTrue(mockEvents->QueryInterface(IID_PPV_ARGS(®ExEvents)) == S_OK);
|
||||
DWORD cookie = 0;
|
||||
Assert::IsTrue(renameRegEx->Advise(regExEvents, &cookie) == S_OK);
|
||||
DWORD flags = MatchAllOccurences | UseRegularExpressions | CaseSensitive;
|
||||
Assert::IsTrue(renameRegEx->PutFlags(flags) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"FOO") == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(L"BAR") == S_OK);
|
||||
Assert::IsTrue(lstrcmpi(L"FOO", mockEvents->m_searchTerm) == 0);
|
||||
Assert::IsTrue(lstrcmpi(L"BAR", mockEvents->m_replaceTerm) == 0);
|
||||
Assert::IsTrue(flags == mockEvents->m_flags);
|
||||
Assert::IsTrue(renameRegEx->UnAdvise(cookie) == S_OK);
|
||||
mockEvents->Release();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "CppUnitTest.h"
|
||||
#include "powerrename/lib/Settings.h"
|
||||
#include <PowerRenameInterfaces.h>
|
||||
#include <PowerRenameRegEx.h>
|
||||
#include "MockPowerRenameRegExEvents.h"
|
||||
@@ -18,8 +19,14 @@ namespace PowerRenameRegExTests
|
||||
|
||||
TEST_CLASS(SimpleTests){
|
||||
public:
|
||||
TEST_METHOD(GeneralReplaceTest){
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
TEST_CLASS_INITIALIZE(ClassInitialize)
|
||||
{
|
||||
CSettingsInstance().SetUseBoostLib(false);
|
||||
}
|
||||
|
||||
TEST_METHOD(GeneralReplaceTest)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(L"foo") == S_OK);
|
||||
@@ -362,6 +369,30 @@ TEST_METHOD(VerifyHandleCapturingGroups)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyLookbehindFails)
|
||||
{
|
||||
// Standard Library Regex Engine does not support lookbehind, thus test should fail.
|
||||
SearchReplaceExpected sreTable[] = {
|
||||
//search, replace, test, result
|
||||
{ L"(?<=E12).*", L"Foo", L"AAAAAA", nullptr },
|
||||
{ L"(?<!E12).*", L"Foo", L"AAAAAA", nullptr },
|
||||
};
|
||||
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
Assert::IsTrue(CPowerRenameRegEx::s_CreateInstance(&renameRegEx) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutFlags(UseRegularExpressions) == S_OK);
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(sreTable); i++)
|
||||
{
|
||||
PWSTR result = nullptr;
|
||||
Assert::IsTrue(renameRegEx->PutSearchTerm(sreTable[i].search) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->PutReplaceTerm(sreTable[i].replace) == S_OK);
|
||||
Assert::IsTrue(renameRegEx->Replace(sreTable[i].test, &result) == E_FAIL);
|
||||
Assert::AreEqual(sreTable[i].expected, result);
|
||||
CoTaskMemFree(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(VerifyEventsFire)
|
||||
{
|
||||
CComPtr<IPowerRenameRegEx> renameRegEx;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="boost" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user