C/C+CLI
clic的Python项目详细描述
clic
A cli tool for c/c++ development.
要求
首先,应该克隆[google/googletest]并在本地计算机中安装CMake。
安装
$ pip install clic
如何使用
安装googletest后,需要在bash配置文件中导出环境GTEST_PATH
(例如.bashrc, .zshrc
,等等)。
$ clic mycpp $ cd mycpp $ tree -L 1 . ├── CMakeLists.txt ├── build ├── lib ├── solution.h └── test.cpp 2 directories, 3 files $ cd build $ cmake .. && make $ ./mycpp ❯ ./mycpp Running main() from ~/mycpp/lib/googletest/googletest/src/gtest_main.cc [==========] Running 1test from 1test suite. [----------] Global test environment set-up. [----------]1test from test[ RUN ] test.INIT Hello mycpp [ OK ] test.INIT (0 ms)[----------]1test from test(0 ms total)[----------] Global test environment tear-down [==========]1test from 1test suite ran. (0 ms total)[ PASSED ]1 test.
如果不想导出GTEST_PATH
环境,可以在以下相同的命令中指定路径:
$ GTEST_PATH=/path/to/cloned/googletest clic my-new-app $ cd my-new-app
现在,享受你的简单C/C++项目吧。
在test.cpp
文件中,可以编写测试。
#include"gtest/gtest.h"#include"gmock/gmock.h"#include"solution.h"#include<iostream>TEST(test,INIT){/* write your test */}
在solution.h
文件中,您可以编写解决方案。
#ifndef MY_SOLUTION__#define MY_SOLUTION__classSolution{public:/* write your solution */};#endif /* ifndef MY_SOLUTION__ */