Index: media/audio/point_unittest.cc |
diff --git a/media/audio/point_unittest.cc b/media/audio/point_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e4deb685dad63a89763ea0f15064225ff4b26b3a |
--- /dev/null |
+++ b/media/audio/point_unittest.cc |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <cmath> |
+ |
+#include "media/audio/point.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace media { |
+namespace { |
+ |
+TEST(PointTest, IsValid) { |
+ { |
+ const Point point; |
+ EXPECT_TRUE(point.IsValid()); |
+ } |
+ { |
+ const Point point(0, -1, 5.5); |
+ EXPECT_TRUE(point.IsValid()); |
+ } |
+ { |
+ const Point point(NAN, 0, 0); |
+ EXPECT_FALSE(point.IsValid()); |
+ } |
+ { |
+ const Point point(0, 0, INFINITY); |
+ EXPECT_FALSE(point.IsValid()); |
+ } |
+} |
+ |
+TEST(PointTest, ToString) { |
+ const std::string point_string = "x=0.000, y=1.000, z=-1.000"; |
+ const Point point(0, 1, -1); |
+ EXPECT_EQ(point_string, point.ToString()); |
+} |
+ |
+TEST(PointTest, ParsePointString) { |
+ const std::vector<Point> expected_empty; |
+ EXPECT_EQ(expected_empty, ParsePointsFromString("")); |
+ EXPECT_EQ(expected_empty, ParsePointsFromString("0 0 a")); |
+ EXPECT_EQ(expected_empty, ParsePointsFromString("1 2")); |
+ EXPECT_EQ(expected_empty, ParsePointsFromString("1 2 3 4")); |
+ |
+ { |
+ std::vector<Point> expected(1, Point(-0.02f, 0, 0)); |
+ expected.push_back(Point(0.02f, 0, 0)); |
+ EXPECT_EQ(expected, ParsePointsFromString("-0.02 0 0 0.02 0 0")); |
+ } |
+ { |
+ std::vector<Point> expected(1, Point(1, 2, 3)); |
+ EXPECT_EQ(expected, ParsePointsFromString("1 2 3")); |
+ } |
+} |
+ |
+} // namespace |
+} // namespace media |