diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/TestCachePrefixKeyParser.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/TestCachePrefixKeyParser.cpp')
-rw-r--r-- | netwerk/test/TestCachePrefixKeyParser.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/netwerk/test/TestCachePrefixKeyParser.cpp b/netwerk/test/TestCachePrefixKeyParser.cpp new file mode 100644 index 000000000..88e544acc --- /dev/null +++ b/netwerk/test/TestCachePrefixKeyParser.cpp @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "TestHarness.h" +#include "nsILoadContextInfo.h" +#include "../cache2/CacheFileUtils.h" + +int +main(int32_t argc, char *argv[]) +{ + nsCOMPtr<nsILoadContextInfo> info; + nsAutoCString key, enh; + +#define CHECK(a) MOZ_ASSERT(a) + + info = ParseKey(NS_LITERAL_CSTRING("")); + CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + info = ParseKey(NS_LITERAL_CSTRING(":")); + CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + info = ParseKey(NS_LITERAL_CSTRING("a,")); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + info = ParseKey(NS_LITERAL_CSTRING("a,:")); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + info = ParseKey(NS_LITERAL_CSTRING("a,:xxx"), &enh, &key); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + CHECK(NS_LITERAL_CSTRING("xxx").Equals(key)); + info = ParseKey(NS_LITERAL_CSTRING("b,:xxx")); + CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 0); + info = ParseKey(NS_LITERAL_CSTRING("a,b,:xxx"), &enh, &key); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 0); + CHECK(NS_LITERAL_CSTRING("xxx").Equals(key)); + CHECK(enh.IsEmpty()); + info = ParseKey(NS_LITERAL_CSTRING("a,b,i123,:xxx")); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123); + info = ParseKey(NS_LITERAL_CSTRING("a,b,c,h***,i123,:xxx"), &enh, &key); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123); + CHECK(NS_LITERAL_CSTRING("xxx").Equals(key)); + info = ParseKey(NS_LITERAL_CSTRING("a,b,c,h***,i123,~enh,:xxx"), &enh, &key); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123); + CHECK(NS_LITERAL_CSTRING("xxx").Equals(key)); + CHECK(NS_LITERAL_CSTRING("enh").Equals(enh)); + info = ParseKey(NS_LITERAL_CSTRING("0x,1,a,b,i123,:xxx")); + CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123); + + nsAutoCString test; + AppendTagWithValue(test, '~', NS_LITERAL_CSTRING("e,nh,")); + info = ParseKey(test, &enh, &key); + CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0); + CHECK(NS_LITERAL_CSTRING("e,nh,").Equals(enh)); + + info = ParseKey(NS_LITERAL_CSTRING("a,i123,b,:xxx")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("a")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("a:")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("a:xxx")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i123")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i123:")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i123:xxx")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i123,x:")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i,x,:")); + CHECK(!info); + info = ParseKey(NS_LITERAL_CSTRING("i:")); + CHECK(!info); + +#undef CHECK + + passed("ok"); + return 0; +} |