OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "net/base/mime_util.h" | 6 #include "net/base/mime_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 TEST(MimeUtilTest, ExtensionTest) { | 11 TEST(MimeUtilTest, ExtensionTest) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const char* original; | 97 const char* original; |
98 size_t expected_size; | 98 size_t expected_size; |
99 const char* results[2]; | 99 const char* results[2]; |
100 } tests[] = { | 100 } tests[] = { |
101 { "\"bogus\"", 1, { "bogus" } }, | 101 { "\"bogus\"", 1, { "bogus" } }, |
102 { "0", 1, { "0" } }, | 102 { "0", 1, { "0" } }, |
103 { "avc1.42E01E, mp4a.40.2", 2, { "avc1", "mp4a" } }, | 103 { "avc1.42E01E, mp4a.40.2", 2, { "avc1", "mp4a" } }, |
104 { "\"mp4v.20.240, mp4a.40.2\"", 2, { "mp4v", "mp4a" } }, | 104 { "\"mp4v.20.240, mp4a.40.2\"", 2, { "mp4v", "mp4a" } }, |
105 { "mp4v.20.8, samr", 2, { "mp4v", "samr" } }, | 105 { "mp4v.20.8, samr", 2, { "mp4v", "samr" } }, |
106 { "\"theora, vorbis\"", 2, { "theora", "vorbis" } }, | 106 { "\"theora, vorbis\"", 2, { "theora", "vorbis" } }, |
107 { "", 0, { } }, | 107 { "", 1, { "" } }, |
108 { "\"\"", 0, { } }, | 108 { "\"\"", 1, { "" } }, |
109 { "\" \"", 0, { } }, | |
110 { ",", 2, { "", "" } }, | 109 { ",", 2, { "", "" } }, |
111 }; | 110 }; |
112 | 111 |
113 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 112 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
114 std::vector<std::string> codecs_out; | 113 std::vector<std::string> codecs_out; |
115 ParseCodecString(tests[i].original, &codecs_out, true); | 114 ParseCodecString(tests[i].original, &codecs_out, true); |
116 ASSERT_EQ(tests[i].expected_size, codecs_out.size()); | 115 EXPECT_EQ(tests[i].expected_size, codecs_out.size()); |
117 for (size_t j = 0; j < tests[i].expected_size; ++j) | 116 for (size_t j = 0; j < tests[i].expected_size; ++j) { |
118 EXPECT_EQ(tests[i].results[j], codecs_out[j]); | 117 EXPECT_EQ(tests[i].results[j], codecs_out[j]); |
| 118 } |
119 } | 119 } |
120 | 120 |
121 // Test without stripping the codec type. | 121 // Test without stripping the codec type. |
122 std::vector<std::string> codecs_out; | 122 std::vector<std::string> codecs_out; |
123 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 123 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
124 ASSERT_EQ(2u, codecs_out.size()); | 124 EXPECT_EQ(2u, codecs_out.size()); |
125 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 125 EXPECT_STREQ("avc1.42E01E", codecs_out[0].c_str()); |
126 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 126 EXPECT_STREQ("mp4a.40.2", codecs_out[1].c_str()); |
127 } | 127 } |
128 | 128 |
129 } // namespace net | 129 } // namespace net |
OLD | NEW |