OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 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 <cmath> | |
6 | |
7 #include "media/audio/point.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 namespace media { | |
11 namespace { | |
12 | |
13 TEST(PointTest, IsValid) { | |
14 { | |
15 const Point point; | |
16 EXPECT_TRUE(point.IsValid()); | |
17 } | |
18 { | |
19 const Point point(0, -1, 5.5); | |
20 EXPECT_TRUE(point.IsValid()); | |
21 } | |
22 { | |
23 const Point point(NAN, 0, 0); | |
24 EXPECT_FALSE(point.IsValid()); | |
25 } | |
26 { | |
27 const Point point(0, 0, INFINITY); | |
ajm
2015/09/02 18:23:04
MSVC gave an "overflow in constant arithmetic" err
| |
28 EXPECT_FALSE(point.IsValid()); | |
29 } | |
30 } | |
31 | |
32 TEST(PointTest, ToString) { | |
33 const std::string point_string = "x=0.000, y=1.000, z=-1.000"; | |
34 const Point point(0, 1, -1); | |
35 EXPECT_EQ(point_string, point.ToString()); | |
36 } | |
37 | |
38 TEST(PointTest, ParsePointString) { | |
39 const std::vector<Point> expected_empty; | |
40 EXPECT_EQ(expected_empty, ParsePointsFromString("")); | |
41 EXPECT_EQ(expected_empty, ParsePointsFromString("0 0 a")); | |
42 EXPECT_EQ(expected_empty, ParsePointsFromString("1 2")); | |
43 EXPECT_EQ(expected_empty, ParsePointsFromString("1 2 3 4")); | |
44 | |
45 { | |
46 std::vector<Point> expected(1, Point(-0.02f, 0, 0)); | |
47 expected.push_back(Point(0.02f, 0, 0)); | |
48 EXPECT_EQ(expected, ParsePointsFromString("-0.02 0 0 0.02 0 0")); | |
49 } | |
50 { | |
51 std::vector<Point> expected(1, Point(1, 2, 3)); | |
52 EXPECT_EQ(expected, ParsePointsFromString("1 2 3")); | |
53 } | |
54 } | |
55 | |
56 } // namespace | |
57 } // namespace media | |
OLD | NEW |