PageRenderTime 18ms CodeModel.GetById 1ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/Common/KSUUIDTest.m

http://macfuse.googlecode.com/
Objective C | 46 lines | 19 code | 11 blank | 16 comment | 0 complexity | ff2a0d8138ea1cf1a550dd350cca89b9 MD5 | raw file
 1// Copyright 2008 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#import <SenTestingKit/SenTestingKit.h>
16#import "KSUUID.h"
17
18
19@interface KSUUIDTest : SenTestCase
20@end
21
22
23@implementation KSUUIDTest
24
25- (void)testBasics {
26  // Make sure we get a reasonable looking string;
27  NSString *uuid1 = [KSUUID uuidString];
28  
29  // Make sure there's character groupings of 8-4-4-4-12
30
31  NSArray *chunks;
32  chunks = [uuid1 componentsSeparatedByString:@"-"];
33  STAssertEquals([chunks count], 5U, nil);
34
35  STAssertEquals([[chunks objectAtIndex:0] length], 8U, nil);
36  STAssertEquals([[chunks objectAtIndex:1] length], 4U, nil);
37  STAssertEquals([[chunks objectAtIndex:2] length], 4U, nil);
38  STAssertEquals([[chunks objectAtIndex:3] length], 4U, nil);
39  STAssertEquals([[chunks objectAtIndex:4] length], 12U, nil);
40
41  // Make sure we don't just keep getting the same string.
42  NSString *uuid2 = [KSUUID uuidString];
43  STAssertFalse([uuid1 isEqualToString:uuid2], nil);
44}
45
46@end