r366137 - [DirectoryWatcher][NFC][test] Add typedef for enum

Jan Korous via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 15:11:29 PDT 2019


Author: jkorous
Date: Mon Jul 15 15:11:28 2019
New Revision: 366137

URL: http://llvm.org/viewvc/llvm-project?rev=366137&view=rev
Log:
[DirectoryWatcher][NFC][test] Add typedef for enum

Modified:
    cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=366137&r1=366136&r2=366137&view=diff
==============================================================================
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Mon Jul 15 15:11:28 2019
@@ -32,6 +32,8 @@ static bool operator==(const DirectoryWa
 
 namespace {
 
+typedef DirectoryWatcher::Event::EventKind EventKind;
+
 struct DirectoryWatcherTestFixture {
   std::string TestRootDir;
   std::string TestWatchedDir;
@@ -81,15 +83,15 @@ struct DirectoryWatcherTestFixture {
   }
 };
 
-std::string eventKindToString(const DirectoryWatcher::Event::EventKind K) {
+std::string eventKindToString(const EventKind K) {
   switch (K) {
-  case DirectoryWatcher::Event::EventKind::Removed:
+  case EventKind::Removed:
     return "Removed";
-  case DirectoryWatcher::Event::EventKind::Modified:
+  case EventKind::Modified:
     return "Modified";
-  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+  case EventKind::WatchedDirRemoved:
     return "WatchedDirRemoved";
-  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+  case EventKind::WatcherGotInvalidated:
     return "WatcherGotInvalidated";
   }
   llvm_unreachable("unknown event kind");
@@ -249,7 +251,6 @@ void checkEventualResultWithTimeout(Veri
       !TestConsumer.result().hasValue())
     TestConsumer.printUnmetExpectations(llvm::outs());
 }
-
 } // namespace
 
 TEST(DirectoryWatcherTest, InitialScanSync) {
@@ -260,9 +261,9 @@ TEST(DirectoryWatcherTest, InitialScanSy
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-       {DirectoryWatcher::Event::EventKind::Modified, "b"},
-       {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+      {{EventKind::Modified, "a"},
+       {EventKind::Modified, "b"},
+       {EventKind::Modified, "c"}},
       {}};
 
   auto DW = DirectoryWatcher::create(
@@ -284,9 +285,9 @@ TEST(DirectoryWatcherTest, InitialScanAs
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-       {DirectoryWatcher::Event::EventKind::Modified, "b"},
-       {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+      {{EventKind::Modified, "a"},
+       {EventKind::Modified, "b"},
+       {EventKind::Modified, "c"}},
       {}};
 
   auto DW = DirectoryWatcher::create(
@@ -305,9 +306,9 @@ TEST(DirectoryWatcherTest, AddFiles) {
 
   VerifyingConsumer TestConsumer{
       {},
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-       {DirectoryWatcher::Event::EventKind::Modified, "b"},
-       {DirectoryWatcher::Event::EventKind::Modified, "c"}}};
+      {{EventKind::Modified, "a"},
+       {EventKind::Modified, "b"},
+       {EventKind::Modified, "c"}}};
 
   auto DW = DirectoryWatcher::create(
       fixture.TestWatchedDir,
@@ -330,8 +331,8 @@ TEST(DirectoryWatcherTest, ModifyFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
+      {{EventKind::Modified, "a"}},
+      {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
       fixture.TestWatchedDir,
@@ -359,8 +360,8 @@ TEST(DirectoryWatcherTest, DeleteFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-      {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-      {{DirectoryWatcher::Event::EventKind::Removed, "a"}}};
+      {{EventKind::Modified, "a"}},
+      {{EventKind::Removed, "a"}}};
 
   auto DW = DirectoryWatcher::create(
       fixture.TestWatchedDir,
@@ -380,8 +381,8 @@ TEST(DirectoryWatcherTest, DeleteWatched
 
   VerifyingConsumer TestConsumer{
       {},
-      {{DirectoryWatcher::Event::EventKind::WatchedDirRemoved, ""},
-       {DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+      {{EventKind::WatchedDirRemoved, ""},
+       {EventKind::WatcherGotInvalidated, ""}}};
 
   auto DW = DirectoryWatcher::create(
       fixture.TestWatchedDir,
@@ -400,7 +401,7 @@ TEST(DirectoryWatcherTest, InvalidatedWa
   DirectoryWatcherTestFixture fixture;
 
   VerifyingConsumer TestConsumer{
-      {}, {{DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+      {}, {{EventKind::WatcherGotInvalidated, ""}}};
 
   {
     auto DW = DirectoryWatcher::create(




More information about the cfe-commits mailing list