blob: d05953d103d28d913ebca5a69564255c7aa6281b [file] [log] [blame]
// 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"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
// Checks that all newly generated groupID are unique and that there are no
// duplicates.
TEST(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(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) {
@"Lynx/2.8.1pre.9 libwww-FM/2.14"));
EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" "));
EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)")