advanced-data-processing-company / vincent

high performance RESTFUL cpp server framework
0 stars 0 forks source link
cpp17 restful-api server

Vincent

Codacy Badge Build Status Build status Total alerts Language grade: JavaScript

Sql design

Source structure

All source files are in src directory, each module has its own sub-directory in src

Build

  1. cd ${VINCENT_ROOT_PATH}
  2. mkdir build && cd build
  3. cmake ..
  4. make or make && make test if you want to excute tests
    cmake -DBUILD_DOC=OFF ..

Git commit message

Reasons for these conventions

Format of git commit message

<type>(<scope>): <subject>
# blank line
<body>
# blank line
<footer>

Example commit message

fix(app): avoid memory leak

use smart pointer to avoid memory leak

#2310

first line

The first line cannot be longer than 70 characters, the second line is always blank and other lines should be wrapped at 80 characters. The type and scope should always be lowercase as shown below.

Allowed \ values

\

Generally <scope> value should be the module name, such as app

\

Briefly concludes modifications

Message body

Footter

issue or feature number

Config git to use commit.template

git config --global commit.template ./.gitcommitstyle.txt

Reference

Unit test

every library should has a executable to do test, test excutable name should end with library name plus _test

take proto for example, its test executable is proto_test,when built you can run test with

cd build
bin/proto_test

and it should give something like

[doctest] doctest version is "2.3.2"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases:      1 |      1 passed |      0 failed |      0 skipped
[doctest] assertions:      4 |      4 passed |      0 failed |
[doctest] Status: SUCCESS!

make && make test

Running tests...
/usr/bin/ctest --force-new-ctest-process 
Test project /home/thy/Documents/vincent/build
    Start 1: proto
1/4 Test #1: proto ............................   Passed    0.00 sec
    Start 2: log
2/4 Test #2: log ..............................   Passed    0.01 sec
    Start 3: config
3/4 Test #3: config ...........................   Passed    0.00 sec
    Start 4: common
4/4 Test #4: common ...........................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.03 sec

How to add a new module

file(GLOB LIB_SRC
    "*.cpp"
    "*.h")

file(GLOB TEST_SRC
    "*test.cpp")

list(REMOVE_ITEM LIB_SRC ${TEST_SRC}})

# add library, replace all `config` with your own `lib_name`
add_library(config ${LIB_SRC})

# add any external lib to your own lib if needed, here is `common`
target_link_libraries(config common)

# add test executable
add_executable(config_test ${TEST_SRC})

add_test(config ${EXECUTABLE_OUTPUT_PATH}/config_test)

# link to lib
target_link_libraries(config_test config)