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

Side by Side Diff: base/cgi_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « base/cgi.cc ('k') | base/clipboard.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2006-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15 //
16 // Unit test for the CGI escape/unescape string..
17
18 #include "base/scoped_ptr.h"
19 #include "omaha/base/cgi.h"
20 #include "omaha/base/string.h"
21 #include "omaha/testing/unit_test.h"
22
23 namespace omaha {
24
25 void TestEscapeUnescape(const TCHAR* origin, const TCHAR* escaped) {
26 int origin_len = lstrlen(origin);
27 int buffer_len = origin_len * CGI::kEscapeFactor + 1;
28 scoped_array<TCHAR> escaped_buffer(new TCHAR[buffer_len]);
29 ASSERT_TRUE(CGI::EscapeString(origin, origin_len,
30 escaped_buffer.get(), buffer_len));
31 ASSERT_STREQ(escaped_buffer.get(), escaped);
32
33 scoped_array<TCHAR> origin_buffer(new TCHAR[buffer_len]);
34 ASSERT_TRUE(CGI::UnescapeString(escaped_buffer.get(),
35 lstrlen(escaped_buffer.get()),
36 origin_buffer.get(), buffer_len));
37 ASSERT_STREQ(origin_buffer.get(), origin);
38 }
39
40 TEST(CGITEST, EscapeUnescape) {
41 // Regular chars.
42 TCHAR origin1[] = _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
43 TestEscapeUnescape(origin1, origin1);
44
45 String_ToLower(origin1);
46 TestEscapeUnescape(origin1, origin1);
47
48 // Special chars.
49 TCHAR origin2[] = _T("^&`{}|][\"<>\\"); // NOLINT
50 TCHAR escaped2[] = _T("%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E%5C");
51 TestEscapeUnescape(origin2, escaped2);
52
53 // Real case.
54 TCHAR origin3[] = _T("http://foo2.bar.google.com:80/pagead/conversion/10679120 86/?ai=123&gclid=456&label=installation&value=0.0"); // NOLIN T
55 TCHAR escaped3[] = _T("http://foo2.bar.google.com:80/pagead/conversion/1067912 086/%3Fai%3D123%26gclid%3D456%26label%3Dinstallation%26value%3D0.0"); // NOLIN T
56 TestEscapeUnescape(origin3, escaped3);
57 }
58
59 } // namespace omaha
60
OLDNEW
« no previous file with comments | « base/cgi.cc ('k') | base/clipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698