OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gfx/point3_f.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace gfx { |
| 11 |
| 12 TEST(Point3Test, VectorArithmetic) { |
| 13 gfx::Point3F a(1.6f, 5.1f, 3.2f); |
| 14 gfx::Vector3dF v1(3.1f, -3.2f, 9.3f); |
| 15 gfx::Vector3dF v2(-8.1f, 1.2f, 3.3f); |
| 16 |
| 17 static const struct { |
| 18 gfx::Point3F expected; |
| 19 gfx::Point3F actual; |
| 20 } tests[] = { |
| 21 { gfx::Point3F(4.7f, 1.9f, 12.5f), a + v1 }, |
| 22 { gfx::Point3F(-1.5f, 8.3f, -6.1f), a - v1 }, |
| 23 { a, a - v1 + v1 }, |
| 24 { a, a + v1 - v1 }, |
| 25 { a, a + gfx::Vector3dF() }, |
| 26 { gfx::Point3F(12.8f, 0.7f, 9.2f), a + v1 - v2 }, |
| 27 { gfx::Point3F(-9.6f, 9.5f, -2.8f), a - v1 + v2 } |
| 28 }; |
| 29 |
| 30 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) |
| 31 EXPECT_EQ(tests[i].expected.ToString(), |
| 32 tests[i].actual.ToString()); |
| 33 } |
| 34 |
| 35 TEST(Point3Test, VectorFromPoints) { |
| 36 gfx::Point3F a(1.6f, 5.2f, 3.2f); |
| 37 gfx::Vector3dF v1(3.1f, -3.2f, 9.3f); |
| 38 |
| 39 gfx::Point3F b(a + v1); |
| 40 EXPECT_EQ((b - a).ToString(), v1.ToString()); |
| 41 } |
| 42 |
| 43 } // namespace gfx |
OLD | NEW |