Chromium Code Reviews| Index: net/cookies/cookie_constants_unittest.cc |
| diff --git a/net/cookies/cookie_constants_unittest.cc b/net/cookies/cookie_constants_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8a87fa0bfb6ae24e603f90e57410ee204abfb1e8 |
| --- /dev/null |
| +++ b/net/cookies/cookie_constants_unittest.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2013 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 "base/basictypes.h" |
| +#include "net/cookies/cookie_constants.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace net { |
| + |
| +namespace { |
| + |
| +class CookieConstantsTest : public testing::Test { }; |
|
erikwright (departed)
2013/04/16 20:25:55
This declaration has no effect and can be removed.
huangs
2013/04/16 20:33:41
Done. Also removed for ParsedCookieTest, which ha
|
| + |
| +} // namespace |
| + |
| +TEST(CookieConstantsTest, TestCookiePriority) { |
| + // Basic cases. |
| + EXPECT_EQ("low", CookiePriorityToString(PRIORITY_LOW)); |
| + EXPECT_EQ("medium", CookiePriorityToString(PRIORITY_MEDIUM)); |
| + EXPECT_EQ("high", CookiePriorityToString(PRIORITY_HIGH)); |
| + |
| + EXPECT_EQ(PRIORITY_LOW, StringToCookiePriority("low")); |
| + EXPECT_EQ(PRIORITY_MEDIUM, StringToCookiePriority("medium")); |
| + EXPECT_EQ(PRIORITY_HIGH, StringToCookiePriority("high")); |
| + |
| + // Case Insensitivity of StringToCookiePriority(). |
| + EXPECT_EQ(PRIORITY_LOW, StringToCookiePriority("LOW")); |
| + EXPECT_EQ(PRIORITY_MEDIUM, StringToCookiePriority("Medium")); |
| + EXPECT_EQ(PRIORITY_HIGH, StringToCookiePriority("hiGH")); |
| + |
| + // Value of default priority. |
| + EXPECT_EQ(PRIORITY_DEFAULT, PRIORITY_MEDIUM); |
| + |
| + // Numeric values. |
| + EXPECT_LT(PRIORITY_LOW, PRIORITY_MEDIUM); |
| + EXPECT_LT(PRIORITY_MEDIUM, PRIORITY_HIGH); |
| + |
| + // Unrecognized tokens are interpreted as PRIORITY_DEFAULT. |
| + char* bad_tokens[] = {"", "lo", "lowerest", "high ", " high", "0"}; |
| + for (int i = 0; i < arraysize(bad_tokens); ++i) { |
| + EXPECT_EQ(PRIORITY_DEFAULT, StringToCookiePriority(bad_tokens[i])); |
| + } |
| +} |
| + |
| +} // namespace net |