forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest_group_util_unittest.mm
38 lines (31 loc) · 1.32 KB
/
request_group_util_unittest.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2014 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.
#import "ios/web/net/request_group_util.h"
#import <Foundation/Foundation.h>
#include <stddef.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using RequestGroupUtilTest = PlatformTest;
// Checks that all newly generated groupID are unique and that there are no
// duplicates.
TEST_F(RequestGroupUtilTest, RequestGroupID) {
NSMutableSet* set = [[NSMutableSet alloc] init];
const size_t kGenerated = 2000;
for (size_t i = 0; i < kGenerated; ++i)
[set addObject:web::GenerateNewRequestGroupID()];
EXPECT_EQ(kGenerated, [set count]);
}
// Tests that the ExtractRequestGroupIDFromUserAgent function behaves as
// intended.
TEST_F(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) {
EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil));
EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(
@"Lynx/2.8.1pre.9 libwww-FM/2.14"));
EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" "));
EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)")
isEqualToString:@"WinNT"]);
}