title: Why does google test sample put tests in an anonymous namespace?
body: <p>This is NOT a duplicate of <a href="https://stackoverflow.com/questions/4422507/superiority-of-unnamed-namespace-over-static">Superiority of unnamed namespace over static?</a>
  Please read the question carefully before marking it as duplicate.  I am <em>not</em> asking why use an unnamed namespace versus static!<br>
  I am asking, why are <em>google tests</em> placed inside an unnamed namespace?  Is this some convention that <em>google tests</em> follow, and if so, why?  The tests work fine whether they are in an unnamed namespace or not, so obviously it is not required.**</p>
  
  <p>I cloned google test from github and built it for my mac.  It works fine, but I noticed in the sample test code they give they place the tests in an unnamed namespace.  Does anyone know why?</p>
  
  <p>For example, see following file: 
  googletest/googletest/samples/sample1_unittest.cc 
  (<a href="https://github.com/google/googletest/blob/master/googletest/samples/sample1_unittest.cc#L41" rel="noreferrer">https://github.com/google/googletest/blob/master/googletest/samples/sample1_unittest.cc#L41</a>)</p>
  
  <p>Part of the file looks like this:</p>
  
  <pre><code>// Step 1. Include necessary header files such that the stuff your
  // test logic needs is declared.
  //
  // Don't forget gtest.h, which declares the testing framework.
  
  #include &lt;limits.h&gt;
  #include "sample1.h"
  #include "gtest/gtest.h"
  namespace {
  
  // Step 2. Use the TEST macro to define your tests.
  ...
  TEST(FactorialTest, Negative) {
  // This test is named "Negative", and belongs to the "FactorialTest"
  // test case.
  EXPECT_EQ(1, Factorial(-5));
  EXPECT_EQ(1, Factorial(-1));
  EXPECT_GT(Factorial(-10), 0);
  }
  ...
  }  // namespace
  </code></pre>
  
  <p>Does anyone know why all the tests are in an unnamed namespace?
  I tried removing the unnamed namespace and the sample still worked fine, so clearly it is not necessary for this particular sample.</p>