Chromium Code Reviews| Index: chrome/installer/mac/app/testing/SystemInfo_test.mm |
| diff --git a/chrome/installer/mac/app/testing/SystemInfo_test.mm b/chrome/installer/mac/app/testing/SystemInfo_test.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..73a056ea7d80ebfc14bd9bcb4c116f9f066cff88 |
| --- /dev/null |
| +++ b/chrome/installer/mac/app/testing/SystemInfo_test.mm |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2016 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. |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +#import "chrome/installer/mac/app/SystemInfo.h" |
| + |
| +namespace { |
| + |
| +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:
|
| + protected: |
| + SystemInfoTest() : Test() { |
| + arch = [SystemInfo getArch]; |
| + os_version = [SystemInfo getOSVersion]; |
| + } |
| + NSString* arch; |
| + NSString* os_version; |
| +}; |
| + |
| +TEST_F(SystemInfoTest, GetArchReturnsExpectedString) { |
| + 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.
|
| + [arch isEqualToString:@"x86_64h"]); |
| +} |
| + |
| +TEST_F(SystemInfoTest, GetOSVersionMatchesRegexFormat) { |
| + 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.
|
| + 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.
|
| + options:0 |
| + error:nil]; |
| + NSUInteger matches = |
| + [regex numberOfMatchesInString:os_version |
| + options:0 |
| + range:NSMakeRange(0, os_version.length)]; |
| + 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
|
| +} |
| + |
| +} // namespace |