Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: media/audio/point_unittest.cc

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a vector instead of a string. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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);
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698