Skip to content

Commit 81326f3

Browse files
committed
add langchain and google_test
1 parent 5264fea commit 81326f3

File tree

14 files changed

+829
-30
lines changed

14 files changed

+829
-30
lines changed

docs/ai/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# AI相关
1+
# 人工智能
22

33
!!! quote ""
44

55
"Artificial intelligence is not a substitute for human intelligence; it is a tool to amplify human creativity and ingenuity."
66

77
-- Fei-Fei Li
88

9+
## 参考资料
910

11+
- [LangChain](https://python.langchain.com/docs/introduction/)
1012

docs/ai/llm/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# LLM
2+
3+
- [LangChain](./langchain.md)
4+

docs/ai/llm/langchain.md

Lines changed: 544 additions & 0 deletions
Large diffs are not rendered by default.

docs/images/ai/know_base.png

945 KB
Loading

docs/images/ai/langchain_tools.png

300 KB
Loading

docs/images/ai/prompt_framework.webp

120 KB
Binary file not shown.

docs/images/ai/rag.png

86.5 KB
Loading

docs/images/tools/git-concept.png

506 KB
Loading

docs/images/tools/git-concept.webp

-14.6 KB
Binary file not shown.

docs/pl/cpp/google_test.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Google Test
2+
3+
谷歌测试框架(Google Test)是一个用于编写和运行 C++ 单元测试的强大且灵活的测试框架。它由 Google 开发并广泛应用于各种 C++ 项目中。它主要的功能如下:
4+
5+
- 断言:支持多种类型的断言,如`ASSERT_EQ``EXPECT_TRUE`等。
6+
- 测试夹具:允许在每个测试之前和之后设置和清理测试环境
7+
- 参数化测试:支持参数化方式运行相同的测试用例
8+
- 死亡测试:支持测试程序在特定条件下是否会正确终止
9+
10+
假如有项目结构如下所示:
11+
```SHELL
12+
goole_test/
13+
├── CMakeLists.txt
14+
├── src
15+
│ ├── add.cpp
16+
│ └── add.h
17+
└── tests
18+
└── test_add.cpp
19+
```
20+
21+
其中源代码文件`src/add.cpp`和头文件`src/add.h`如下所示:
22+
23+
```CPP
24+
// add.h
25+
#ifndef ADD_H
26+
#define ADD_H
27+
28+
int add(int a, int b);
29+
30+
#endif // ADD_H
31+
32+
// add.cpp
33+
#include "add.h"
34+
35+
int add(int a, int b) {
36+
return a + b;
37+
}
38+
```
39+
40+
测试文件`tests/test_add.cpp`如下所示:
41+
42+
```CPP
43+
#include "gtest/gtest.h"
44+
#include "add.h"
45+
46+
47+
TEST(AdditionTest, PositiveNumbers) {
48+
EXPECT_EQ(add(2, 3), 5);
49+
}
50+
51+
TEST(AdditionTest, NegativeNumbers) {
52+
EXPECT_EQ(add(-2, -3), -5);
53+
}
54+
55+
TEST(AdditionTest, MixedNumbers) {
56+
EXPECT_EQ(add(-2, 3), 1);
57+
}
58+
```
59+
60+
CMakeLists.txt 文件如下所示:
61+
62+
```CMAKE
63+
cmake_minimum_required(VERSION 3.10)
64+
project(MyProject)
65+
66+
# 查找Google Test库
67+
find_package(GTest REQUIRED)
68+
69+
# 包含头文件目录
70+
include_directories(src)
71+
72+
# 添加可执行文件
73+
add_executable(test tests/test_add.cpp src/add.cpp)
74+
75+
# 链接Google Test库(包括默认main函数)和线程库
76+
target_link_libraries(test GTest::GTest GTest::Main)
77+
```

0 commit comments

Comments
 (0)