Skip to content

Commit 1a06ad5

Browse files
committed
Cleaned up example code comments
1 parent ab8439f commit 1a06ad5

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

docs/testing/unit_testing.md

+38-38
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ of test functions in a given source file is called a "suite".
2929
3030
TEST(YourTestFunction1)
3131
{
32-
//// Do some test things here, then check the results using EXPECT_*
32+
// Do some test things here, then check the results using EXPECT_*
3333
SomeTypeX foo;
3434
foo.DoSomething();
3535
EXPECT_EQ(foo.GetResultCount(), 7);
3636
foo.DoSomethingElse();
3737
EXPECT_EQ(foo.GetResultCount(), 5);
3838
39-
//// If you want to abort the rest of the test upon failure, use ASSERT_*
39+
// If you want to abort the rest of the test upon failure, use ASSERT_*
4040
SomeTypeY * ptr = foo.GetSomePointer();
4141
ASSERT_NE(ptr, nullptr);
4242
ptr->DoTheThing(); // Won't reach here if the ASSERT failed.
4343
}
4444
4545
TEST(YourTestFunction2)
4646
{
47-
//// Do some test things here, then check the results using EXPECT_*
47+
// Do some test things here, then check the results using EXPECT_*
4848
SomeTypeZ foo;
4949
foo.DoSomething();
5050
EXPECT_EQ(foo.GetResultCount(), 3);
@@ -74,59 +74,59 @@ public:
7474
// Performs shared setup for all tests in the test suite. Run once for the whole suite.
7575
static void SetUpTestSuite()
7676
{
77-
//// Your per-suite setup goes here:
78-
// sPerSuiteFixture.Init();
79-
// ASSERT_TRUE(sPerSuiteFixture.WorkingGreat());
77+
// Your per-suite setup goes here:
78+
sPerSuiteFixture.Init();
79+
ASSERT_TRUE(sPerSuiteFixture.WorkingGreat());
8080
}
8181
8282
// Performs shared teardown for all tests in the test suite. Run once for the whole suite.
8383
static void TearDownTestSuite()
8484
{
85-
//// Your per-suite teardown goes here:
86-
// sPerSuiteFixture.Shutdown();
85+
// Your per-suite teardown goes here:
86+
sPerSuiteFixture.Shutdown();
8787
}
8888
8989
protected:
9090
// Performs setup for each test in the suite. Run once for each test function.
9191
void SetUp()
9292
{
93-
//// Your per-test setup goes here:
94-
// mPerTestFixture.Init();
95-
// ASSERT_TRUE(mPerTestFixture.WorkingGreat());
93+
// Your per-test setup goes here:
94+
mPerTestFixture.Init();
95+
ASSERT_TRUE(mPerTestFixture.WorkingGreat());
9696
}
9797
9898
// Performs teardown for each test in the suite. Run once for each test function.
9999
void TearDown()
100100
{
101-
//// Your per-test teardown goes here:
102-
// mPerTestFixture.Shutdown();
101+
// Your per-test teardown goes here:
102+
mPerTestFixture.Shutdown();
103103
}
104104
105105
private:
106-
//// Your per-suite and per-test fixtures are declared here:
107-
// static SomeTypeA sPerSuiteFixture;
108-
// SomeTypeB mPerTestFixture;
106+
// Your per-suite and per-test fixtures are declared here:
107+
static SomeTypeA sPerSuiteFixture;
108+
SomeTypeB mPerTestFixture;
109109
};
110-
//// Your per-suite fixtures are defined here:
111-
// SomeTypeA YourTestContext::sPerSuiteFixture;
110+
// Your per-suite fixtures are defined here:
111+
SomeTypeA YourTestContext::sPerSuiteFixture;
112112
113113
TEST_F(YourTestContext, YourTestFunction1)
114114
{
115-
//// Do some test things here, then check the results using EXPECT_*
115+
// Do some test things here, then check the results using EXPECT_*
116116
mPerTestFixture.DoSomething();
117117
EXPECT_EQ(mPerTestFixture.GetResultCount(), 7);
118118
sPerSuiteFixture.DoSomething();
119119
EXPECT_EQ(sPerSuiteFixture.GetResultCount(), 5);
120120
121-
//// If you want to abort the rest of the test upon failure, use ASSERT_*
121+
// If you want to abort the rest of the test upon failure, use ASSERT_*
122122
SomeTypeC * ptr = mPerTestFixture.GetSomePointer();
123123
ASSERT_NE(ptr, nullptr);
124124
ptr->DoTheThing(); // Won't reach here if the ASSERT failed.
125125
}
126126
127127
TEST_F(YourTestContext, YourTestFunction2)
128128
{
129-
//// Do some test things here, then check the results using EXPECT_*
129+
// Do some test things here, then check the results using EXPECT_*
130130
mPerTestFixture.DoSomethingElse();
131131
EXPECT_EQ(mPerTestFixture.GetResultCount(), 9);
132132
}
@@ -152,16 +152,16 @@ public:
152152
AppContext::SetUpTestSuite(); // Call parent.
153153
VerifyOrReturn(!HasFailure()); // Stop if parent had a failure.
154154
155-
//// Your per-suite setup goes here:
156-
// sPerSuiteFixture.Init();
157-
// ASSERT_TRUE(sPerSuiteFixture.WorkingGreat());
155+
// Your per-suite setup goes here:
156+
sPerSuiteFixture.Init();
157+
ASSERT_TRUE(sPerSuiteFixture.WorkingGreat());
158158
}
159159
160160
// Performs shared teardown for all tests in the test suite. Run once for the whole suite.
161161
static void TearDownTestSuite()
162162
{
163-
//// Your per-suite teardown goes here:
164-
// sPerSuiteFixture.Shutdown();
163+
// Your per-suite teardown goes here:
164+
sPerSuiteFixture.Shutdown();
165165
166166
AppContext::TearDownTestSuite(); // Call parent.
167167
}
@@ -173,37 +173,37 @@ protected:
173173
AppContext::SetUp(); // Call parent.
174174
VerifyOrReturn(!HasFailure()); // Stop if parent had a failure.
175175
176-
//// Your per-test setup goes here:
177-
// mPerTestFixture.Init();
178-
// ASSERT_TRUE(mPerTestFixture.WorkingGreat());
176+
// Your per-test setup goes here:
177+
mPerTestFixture.Init();
178+
ASSERT_TRUE(mPerTestFixture.WorkingGreat());
179179
}
180180
181181
// Performs teardown for each test in the suite. Run once for each test function.
182182
void TearDown()
183183
{
184-
//// Your per-test teardown goes here:
185-
// mPerTestFixture.Shutdown();
184+
// Your per-test teardown goes here:
185+
mPerTestFixture.Shutdown();
186186
187187
chip::app::EventManagement::DestroyEventManagement();
188188
AppContext::TearDown(); // Call parent.
189189
}
190190
191191
private:
192-
//// Your per-suite and per-test fixtures are declared here:
193-
// static SomeTypeA sPerSuiteFixture;
194-
// SomeTypeB mPerTestFixture;
192+
// Your per-suite and per-test fixtures are declared here:
193+
static SomeTypeA sPerSuiteFixture;
194+
SomeTypeB mPerTestFixture;
195195
};
196-
//// Your per-suite fixtures are defined here:
197-
// SomeTypeA YourTestContext::sPerSuiteFixture;
196+
// Your per-suite fixtures are defined here:
197+
SomeTypeA YourTestContext::sPerSuiteFixture;
198198
199199
TEST_F(YourTestContext, YourTestFunction1)
200200
{
201-
//// Do some test things here, then check the results using EXPECT_*
201+
// Do some test things here, then check the results using EXPECT_*
202202
}
203203
204204
TEST_F(YourTestContext, YourTestFunction2)
205205
{
206-
//// Do some test things here, then check the results using EXPECT_*
206+
// Do some test things here, then check the results using EXPECT_*
207207
}
208208
```
209209

0 commit comments

Comments
 (0)