Revert D4832473: [Folly] Disable EnvUtil::setAsCurrentEnvironment() on platforms...
[folly.git] / folly / test / RangeTest.cpp
index d4f658653fb340c2dc0b91e4a94e10ab693917bb..8f333403a174fe2832d12446cb5bc25bae62b5f6 100644 (file)
@@ -315,6 +315,15 @@ TEST(StringPiece, Prefix) {
   EXPECT_FALSE(a.startsWith('x'));
   EXPECT_FALSE(a.startsWith("x"));
 
+  EXPECT_TRUE(a.startsWith("", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.startsWith("hello", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.startsWith("hellO", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.startsWith("HELL", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.startsWith("H", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.startsWith("HELLOX", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.startsWith("x", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.startsWith("X", folly::AsciiCaseInsensitive()));
+
   {
     auto b = a;
     EXPECT_TRUE(b.removePrefix(""));
@@ -362,6 +371,16 @@ TEST(StringPiece, Suffix) {
   EXPECT_FALSE(a.endsWith("x"));
   EXPECT_FALSE(a.endsWith('x'));
 
+  EXPECT_TRUE(a.endsWith("", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.endsWith("o", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.endsWith("O", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.endsWith("hello", folly::AsciiCaseInsensitive()));
+  EXPECT_TRUE(a.endsWith("hellO", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.endsWith("xhello", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.endsWith("Xhello", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.endsWith("x", folly::AsciiCaseInsensitive()));
+  EXPECT_FALSE(a.endsWith("X", folly::AsciiCaseInsensitive()));
+
   {
     auto b = a;
     EXPECT_TRUE(b.removeSuffix(""));
@@ -1093,14 +1112,10 @@ TEST(RangeFunc, Array) {
   testRangeFunc(x, 3);
 }
 
-// MSVC doesn't like it when you try to std::move C arrays:
-// https://developercommunity.visualstudio.com/content/problem/2441/
-#ifndef _MSC_VER
 TEST(RangeFunc, CArray) {
   int x[] {1, 2, 3, 4};
   testRangeFunc(x, 4);
 }
-#endif
 
 TEST(RangeFunc, ConstexprCArray) {
   static constexpr const int numArray[4] = {3, 17, 1, 9};
@@ -1114,15 +1129,8 @@ TEST(RangeFunc, ConstexprStdArray) {
   static constexpr const std::array<int, 4> numArray = {{3, 17, 1, 9}};
   constexpr const auto numArrayRange = range(numArray);
   EXPECT_EQ(17, numArrayRange[1]);
-  // MSVC 2017 RC and earlier have an issue that causes the beginning and
-  // end of numArrayRange to point to different copies of numArray, causing
-  // this attempt to calculate the size to error at compile time because
-  // they don't point to parts of the same array :(
-  // https://developercommunity.visualstudio.com/content/problem/3216/
-#if !defined(_MSC_VER) || _MSC_VER > 191024629
   constexpr const auto numArrayRangeSize = numArrayRange.size();
   EXPECT_EQ(4, numArrayRangeSize);
-#endif
 }
 
 TEST(RangeFunc, ConstexprStdArrayZero) {