Chromium Code Reviews| 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 "chrome/browser/chromeos/system_logs/lsbrelease_log_source.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace chromeos { | |
| 11 | |
| 12 TEST(LSBReleaseLogSource, BasicFunctionality) { | |
| 13 std::string data("key=value\nkey2 = value2 "); | |
| 14 SystemLogsResponse response; | |
| 15 LsbReleaseLogSource::ParseLSBRelease(data, &response); | |
| 16 EXPECT_EQ(2U, response.size()); | |
| 17 EXPECT_EQ("value", response["key"]); | |
| 18 EXPECT_TRUE(response.find("key2") != response.end()); | |
|
satorux1
2012/08/15 22:01:09
remove this?
tudalex(Chromium)
2012/08/16 01:08:57
No. It checks if the spaces we're removed correctl
satorux1
2012/08/16 10:50:57
ah that makes sense.
| |
| 19 EXPECT_EQ("value2", response["key2"]); | |
|
satorux1
2012/08/15 22:01:09
might want to add some comment:
// Make sure extr
tudalex(Chromium)
2012/08/16 01:08:57
Done.
| |
| 20 } | |
| 21 | |
| 22 TEST(LSBReleaseLogSource, ValueMissing) { | |
| 23 std::string data("key=value\nkey2=\nkey3"); | |
| 24 SystemLogsResponse response; | |
| 25 LsbReleaseLogSource::ParseLSBRelease(data, &response); | |
| 26 EXPECT_EQ(2U, response.size()); | |
| 27 EXPECT_EQ("value", response["key"]); | |
| 28 EXPECT_EQ("<no value>", response["key2"]); | |
| 29 EXPECT_FALSE(response.find("key3") != response.end()); | |
|
satorux1
2012/08/15 22:01:09
you can do:
EXPECT_EQ(0U, response.count("key3"))
| |
| 30 } | |
| 31 | |
| 32 TEST(LSBReleaseLogSource, UTF8) { | |
|
satorux1
2012/08/15 22:01:09
BrokenUTF8
tudalex(Chromium)
2012/08/16 01:08:57
Done.
| |
| 33 std::string data("key=value\nkey2=\nkey3="); | |
|
satorux1
2012/08/15 22:01:09
you could do "key=value\nkey2=\nkey3=\xFC" and rem
tudalex(Chromium)
2012/08/16 01:08:57
Done.
| |
| 34 data.push_back(253); | |
| 35 data.append("ts\nkey4=value4"); | |
| 36 SystemLogsResponse response; | |
| 37 LsbReleaseLogSource::ParseLSBRelease(data, &response); | |
| 38 EXPECT_EQ("<invalid characters in log entry>", response["key3"]); | |
| 39 EXPECT_EQ("value4", response["key4"]); | |
| 40 } | |
| 41 | |
| 42 TEST(LSBReleasLogSource, NoKeyValuePair) { | |
|
satorux1
2012/08/15 22:01:09
you might also want to test with an empty string.
tudalex(Chromium)
2012/08/16 01:08:57
Done.
| |
| 43 std::string data("random text without a meaning"); | |
| 44 SystemLogsResponse response; | |
| 45 LsbReleaseLogSource::ParseLSBRelease(data, &response); | |
| 46 EXPECT_TRUE(response.empty()); | |
| 47 } | |
| 48 | |
| 49 } // namespace chromeos | |
| OLD | NEW |