添加并高亮代码块
添加代码块
步骤
- 在需要高亮的代码块的前一行及后一行使用三个反引号:``` (键盘左上角第二排~键)
- 同时第一行反引号后面,输入代码块所使用的语言。
例子
编辑器中输入一下代码块:
```c++
class FooTest : public ::testing::Test {
protected:
// Per-test-case set-up.
// Called before the first test in this test case.
// Can be omitted if not needed.
static void SetUpTestCase() {
shared_resource_ = new ...;
}
// Per-test-case tear-down.
// Called after the last test in this test case.
// Can be omitted if not needed.
static void TearDownTestCase() {
delete shared_resource_;
shared_resource_ = NULL;
}
// You can define per-test set-up logic as usual.
virtual void SetUp() { ... }
// You can define per-test tear-down logic as usual.
virtual void TearDown() { ... }
// Some expensive resource shared by all tests.
static T* shared_resource_;
};
T* FooTest::shared_resource_ = NULL;
TEST_F(FooTest, Test1) {
... you can refer to shared_resource_ here ...
}
TEST_F(FooTest, Test2) {
... you can refer to shared_resource_ here ...
}
```
渲染后的效果:
class FooTest : public ::testing::Test {
protected:
// Per-test-case set-up.
// Called before the first test in this test case.
// Can be omitted if not needed.
static void SetUpTestCase() {
shared_resource_ = new ...;
}
// Per-test-case tear-down.
// Called after the last test in this test case.
// Can be omitted if not needed.
static void TearDownTestCase() {
delete shared_resource_;
shared_resource_ = NULL;
}
// You can define per-test set-up logic as usual.
virtual void SetUp() { ... }
// You can define per-test tear-down logic as usual.
virtual void TearDown() { ... }
// Some expensive resource shared by all tests.
static T* shared_resource_;
};
T* FooTest::shared_resource_ = NULL;
TEST_F(FooTest, Test1) {
... you can refer to shared_resource_ here ...
}
TEST_F(FooTest, Test2) {
... you can refer to shared_resource_ here ...
}