summaryrefslogtreecommitdiff
path: root/tests/src/CoreMangLib/cti/system
diff options
context:
space:
mode:
authorErti-Chris Eelmaa <chriseelmaa@gmail.com>2017-02-14 16:35:16 +0000
committerTarek Mahmoud Sayed <tarekms@microsoft.com>2017-02-14 08:35:16 -0800
commitd0f8481cd42e58013879326871455586a86bec6e (patch)
tree39e51171f99801e56a9e167cd56dbb1ff4d40791 /tests/src/CoreMangLib/cti/system
parent3e7d8a5deb0cb761b848e0370e57cf64b283c4f4 (diff)
downloadcoreclr-d0f8481cd42e58013879326871455586a86bec6e.tar.gz
coreclr-d0f8481cd42e58013879326871455586a86bec6e.tar.bz2
coreclr-d0f8481cd42e58013879326871455586a86bec6e.zip
Add case-insensitive String.Replace overloads (#9316)
Added overloads for String.Replace so that they now accept StringComparison and CultureInfo as input parameters.
Diffstat (limited to 'tests/src/CoreMangLib/cti/system')
-rw-r--r--tests/src/CoreMangLib/cti/system/string/StringReplace3.csproj42
-rw-r--r--tests/src/CoreMangLib/cti/system/string/stringreplace3.cs75
2 files changed, 117 insertions, 0 deletions
diff --git a/tests/src/CoreMangLib/cti/system/string/StringReplace3.csproj b/tests/src/CoreMangLib/cti/system/string/StringReplace3.csproj
new file mode 100644
index 0000000000..5addaf30c1
--- /dev/null
+++ b/tests/src/CoreMangLib/cti/system/string/StringReplace3.csproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4AC1-495E-87D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="stringreplace3.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/string/stringreplace3.cs b/tests/src/CoreMangLib/cti/system/string/stringreplace3.cs
new file mode 100644
index 0000000000..88c20af10b
--- /dev/null
+++ b/tests/src/CoreMangLib/cti/system/string/stringreplace3.cs
@@ -0,0 +1,75 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+
+/// <summary>
+/// String.Replace(String, String)
+/// Replaces all occurrences of a specified Unicode character in this instance
+/// with another specified Unicode character.
+/// </summary>
+public class StringReplace3
+{
+ public static int Main()
+ {
+ int result = Test1() && Test2() && Test3() && Test4() && Test5() && Test6() && Test7() ? 100 : -1;
+
+ return result;
+ }
+
+ private static bool Test1()
+ {
+ string strExpected = "Test HEY with HEYAND HEY";
+ string strActual = "Test %token% with %TOKEN%AND %tokeN%".Replace("%token%", "HEY", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test2()
+ {
+ string strExpected = "Test HEY with HEYAND Test!";
+ string strActual = "Test %token% with %TOKEN%AND Test!".Replace("%token%", "HEY", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test3()
+ {
+ string strExpected = "HEYTest HEY with HEYAND Test!";
+ string strActual = "%TOKEN%Test %token% with %TOKEN%AND Test!".Replace("%token%", "HEY", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test4()
+ {
+ string strExpected = "HEYHEYTest HEY with HEYAND Test!";
+ string strActual = "%TOKEN%%token%Test %token% with %TOKEN%AND Test!".Replace("%token%", "HEY", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test5()
+ {
+ string strExpected = "dof";
+ string strActual = "d\u00e9f".Replace("e\u0301", "o", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test6()
+ {
+ string strExpected = "dof";
+ string strActual = "de\u0301f".Replace("\u00e9", "o", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+
+ private static bool Test7()
+ {
+ string strExpected = "dfo";
+ string strActual = "de\u0301fo".Replace("\u00e9", "", StringComparison.InvariantCultureIgnoreCase);
+
+ return strExpected == strActual;
+ }
+}