Skip to content

This tool helps me to generate a new class including its source and header files, and its test file's source code according to googletest framework

License

Notifications You must be signed in to change notification settings

clockzhong/CPPGenerator

Repository files navigation

This CPPGenerator is used to generate C++ source codes, which include the classes' *.cpp, and *.hpp, their tests(for googletest) and corresponding makefile content.
We could use this tool to eliminate the repeated, routine and tedious work which we must do when creating a new class in our C++ source tree.
The primary tasks it could help us do include:
1. The main input parameter for this tool is the "class" name;
2. It could generate the class.cpp(in ./src directory), class.hpp(in ./inc directory);
3. It could change the Makefile which could help me finish the codes in Makefile on compiling and linking the class.cpp file;
4. It also could generate template codes for testClass.cpp, which will use GoogleTest framework to implement the testing logic. The real testing logic should be designed manually.

The steps to create an example project on how to use this tool:
Objective: we need create a project which name is: MyExampleProject, and create two classes(MyClassA and MyClassB) in this project, and at the same time, create these two classes' UAT based on GoogleTest(https://github.com/google/googletest)
1. initCPPProject.py MyExampleProject
2. cd MyExampleProject
3. genClass.py MyClassA ; genClass.py MyClassB 
4. ./bt.sh testMyClassA ; ./bt.sh testMyClassB
The last step(4) will use GoogleTest to test your newly created class:MyClassA&MyClassB, their corresponding tests applications are: testMyClassA and testMyClassB. You also could manually change them in ./MyExampleProject/tests
This template project generated by this tool(initCPPProject.py) includes the 3rd parties' GoogleTest framework on UAT support and easylogging++ framework on LOGGING support. You also need define GOOGLETEST_ROOT_PATH and EASYLOGGINGPP_HEADER_PATH before you start using this tool, or the last step(step 4) couldn't work correctly. If you don't want to do the test automatically, and just want this tool to generate the classes' C++ source&header files, you could comment the test related codes in the template. The "bt.sh" means "building&testing".

   zhong.clock@gmail.com

About

This tool helps me to generate a new class including its source and header files, and its test file's source code according to googletest framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published