title: c++ and gtest, need help understanding why seemingly simple test fails
body: <p>I have recently started using <em>googletest</em> to set up some unit-testing and ran into a situation which I don't understand. The test fails but everything looks like it would pass.</p>
  
  <p>I have a small struct similar to this:</p>
  
  <pre><code>struct vec2 { float x, y; }
  </code></pre>
  
  <p>a function:</p>
  
  <pre><code>vec2 vec2_add_scalar (vec2 v, float scalar) {
      return {v.x + scalar, v.y + scalar};
  }
  </code></pre>
  
  <p>and the test:</p>
  
  <pre><code>TEST (math_test, add_scalar) {
      vec2 v {4.0f, -4.0f};
      float s = 3.14f;
  
      vec2 r = vec2_add_scalar(v, s);
  
      EXPECT_EQ (7.14f, r.x);
      EXPECT_EQ (-0.86f, r.y);
  }
  </code></pre>
  
  <p>When running the test this is what I get:</p>
  
  <pre><code>[ RUN      ] vector2_test.add_scalar
  vec2_test.cpp: Failure
      Expected: 7.14
  To be equal to: r.x
      Which is: 7.14
  </code></pre>
  
  <p>I don't understand why the test fails, and would appreciate help in figuring out what might make the test  fail.</p>