allow AsyncSignalHandler to attach and detach from an EventBase
[folly.git] / folly / test / ForeachTest.cpp
index 9904084d631ce816280e265559c0903a85179789..367c3a42e9f77fe2add900bbf0e9b26a698f43ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,18 @@ TEST(Foreach, ForEachRvalue) {
   EXPECT_EQ(0, n);
 }
 
+TEST(Foreach, ForEachNested) {
+  const std::string hello = "hello";
+  size_t n = 0;
+  FOR_EACH(i, hello) {
+    FOR_EACH(j, hello) {
+      ++n;
+    }
+  }
+  auto len = hello.size();
+  EXPECT_EQ(len * len, n);
+}
+
 TEST(Foreach, ForEachKV) {
   std::map<std::string, int> testMap;
   testMap["abc"] = 1;