Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(843)

Side by Side Diff: chrome/installer/mac/app/testing/SystemInfo_test.mm

Issue 2137743002: Added test files for SystemInfo.m and OmahaXMLRequest.m. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Transitioned fully to super-concise tests; ready for more comments! Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698