Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 | |
| 7 #import "chrome/installer/mac/app/SystemInfo.h" | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 class SystemInfoTest : public ::testing::Test { | |
|
Mark Mentovai
2016/07/22 15:42:38
We shouldn’t have a test class here or any TEST_F.
Anna Zeng
2016/07/22 16:58:03
So I know that fixtures are used when each test re
Mark Mentovai
2016/07/22 18:03:24
Anna Zeng wrote:
| |
| 12 protected: | |
| 13 SystemInfoTest() : Test() { | |
| 14 arch = [SystemInfo getArch]; | |
| 15 os_version = [SystemInfo getOSVersion]; | |
| 16 } | |
| 17 NSString* arch; | |
| 18 NSString* os_version; | |
| 19 }; | |
| 20 | |
| 21 TEST_F(SystemInfoTest, GetArchReturnsExpectedString) { | |
| 22 EXPECT_TRUE([arch isEqualToString:@"i486"] || | |
|
Mark Mentovai
2016/07/22 15:42:38
This should just be TEST(SystemInfoTest, GetArchRe
Anna Zeng
2016/07/22 16:58:03
Done.
| |
| 23 [arch isEqualToString:@"x86_64h"]); | |
| 24 } | |
| 25 | |
| 26 TEST_F(SystemInfoTest, GetOSVersionMatchesRegexFormat) { | |
| 27 NSRegularExpression* regex = [NSRegularExpression | |
|
Mark Mentovai
2016/07/22 15:42:38
Similar here, just get the OS version right here i
Anna Zeng
2016/07/22 16:58:02
Done.
| |
| 28 regularExpressionWithPattern:@"^10\\.[0-9]+\\.[0-9]+$" | |
|
Mark Mentovai
2016/07/22 15:42:38
We can make the regex even tighter:
"^10\\.(0|[1-
Anna Zeng
2016/07/22 16:58:02
Oh wow, good point! Done.
| |
| 29 options:0 | |
| 30 error:nil]; | |
| 31 NSUInteger matches = | |
| 32 [regex numberOfMatchesInString:os_version | |
| 33 options:0 | |
| 34 range:NSMakeRange(0, os_version.length)]; | |
| 35 EXPECT_EQ((int)matches, 1); | |
|
Mark Mentovai
2016/07/22 15:42:38
Rather than a cast to int, you can say 1u, which m
Anna Zeng
2016/07/22 16:58:02
Thanks for the tip! Looking closer at NSInteger/NS
Mark Mentovai
2016/07/22 18:03:24
Anna Zeng wrote:
Anna Zeng
2016/07/22 18:38:32
This is an amazing book Mark! I highly recommend t
| |
| 36 } | |
| 37 | |
| 38 } // namespace | |
| OLD | NEW |