title: How does gtest compare the values in two arrays?
body: <p>I have read <a href="https://github.com/google/googletest/blob/master/googletest/docs/primer.md#assertions" rel="nofollow noreferrer">this official document</a>, learn how to do Binary Comparison and String Comparison.</p>
  
  <p>The ASSERT_EQ and ASSERT_STREQ could not work in the array comparison case.</p>
  
  <p>For example</p>
  
  <pre><code>li@li:~/poc$ g++ -I${GTEST_DIR}/include insertion_sort.cpp insertion_sort_unittest.cpp /home/li/libgtest.a -lpthread -o inser_unit
  li@li:~/poc$ ./inser_unit 
  [==========] Running 1 test from 1 test case.
  [----------] Global test environment set-up.
  [----------] 1 test from InsertionSortTest
  [ RUN      ] InsertionSortTest.Two
  insertion_sort_unittest.cpp:18: Failure
  Value of: two_sorted
    Actual: { 2, 5 }
  Expected: two
  Which is: { 2, 5 }
  [  FAILED  ] InsertionSortTest.Two (1 ms)
  [----------] 1 test from InsertionSortTest (1 ms total)
  
  [----------] Global test environment tear-down
  [==========] 1 test from 1 test case ran. (1 ms total)
  [  PASSED  ] 0 tests.
  [  FAILED  ] 1 test, listed below:
  [  FAILED  ] InsertionSortTest.Two
  
   1 FAILED TEST
  </code></pre>
  
  <p>insertion_sort_unittest.cpp</p>
  
  <pre><code>#include &lt;limits.h&gt;
  #include "insertionsort.h"
  #include "gtest/gtest.h"
  
  namespace{
      class InsertionSortTest : public ::testing::Test{
          protected:
              InsertionSortTest() {}
              virtual ~InsertionSortTest() {}
              virtual void SetUp() {}
              virtual void TearDown() {}
      };
  
      TEST(InsertionSortTest, Two){
          int two[] = {5, 2};
          int two_sorted[] = {2, 5};
          insertionSort(two, 2);
          EXPECT_EQ(two, two_sorted);
      }
  }
  
  int main(int argc, char **argv){
      ::testing::InitGoogleTest(&amp;argc, argv);
      return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>insertion_sort.cpp</p>
  
  <pre><code>#include "insertionsort.h"
  void insertionSort(int *data, int size){
      for (int i=1,j; i&lt;size; i++){
          int key = data[i];
          for (j=i-1; j&gt;=0; j--){
              if (data[j] &gt; key){
                  data[j+1]=data[j];
                  data[j]=key;
              }
          }
      }
  }
  </code></pre>
  
  <p>insertionsort.h</p>
  
  <pre><code>#ifndef INSERTIONSORT_H_
  #define INSERTIONSORT_H_
  void insertionSort(int *data, int size);
  #endif
  </code></pre>