Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Google C/C++ Code Style settings
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# Author: Kehan Xue, kehan.xue (at) gmail.com

Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterStruct: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 80
CompactNamespaces: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false # Make sure the * or & align on the left
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
# SeparateDefinitionBlocks: Always # Only support since clang-format 14
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 4
UseTab: Never
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ set(APP_SOURCES
"src/DeleteMe.cpp"
"src/core/basics/InitializeVariable.cpp"
"src/core/basics/Operations.cpp"
"src/core/basics/TypeQualifier.cpp"
"src/core/basics/ControlFlow.cpp"
"src/core/datatypes/Fundamental.cpp"
"src/core/datatypes/CArray.cpp"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ Make sure the following tools are installed before building the project:
- **Git**
- **lcov** (for code coverage)
- **cppcheck** (for static analysis)
- **Optional:** Install `clang-format` to format C++ code.

Linux
```bash
sudo apt install clang-format
find . -regex '.*\.\(cpp\|h\|hpp\)' -exec clang-format -i {} \;
```
Windows
```bash
# Install clang-format via Chocolatey
choco install clang-format

# Apply clang-format recursively to .cpp, .h, .hpp files
Get-ChildItem -Recurse -Include *.cpp, *.h, *.hpp | ForEach-Object { clang-format -i $_.FullName }
```
## 3. SETUP
* Setup the Local Test Environment
* 1.Using your own Ubuntu system
Expand Down
21 changes: 10 additions & 11 deletions include/DeleteMe.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#pragma once
class DeleteMe
{
private:
int m_lastResult;
class DeleteMe {
private:
int m_lastResult;

public:
DeleteMe();
~DeleteMe();
bool add(int addend1, int addend2);
bool mul(int factor1, int factor2);
bool div(int dividend, int divisor);
int get_last_result();
public:
DeleteMe();
~DeleteMe();
bool add(int addend1, int addend2);
bool mul(int factor1, int factor2);
bool div(int dividend, int divisor);
int get_last_result();
};
45 changes: 18 additions & 27 deletions src/DeleteMe.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
#include "DeleteMe.h"

DeleteMe::DeleteMe()
{
m_lastResult = 0;
DeleteMe::DeleteMe() {
m_lastResult = 0;
}

DeleteMe::~DeleteMe()
{

}
DeleteMe::~DeleteMe() {}

bool DeleteMe::add(int addend1, int addend2)
{
m_lastResult = addend1 + addend2;
return true;
bool DeleteMe::add(int addend1, int addend2) {
m_lastResult = addend1 + addend2;
return true;
}

// This is for checking that code coverage will not be <100%
bool DeleteMe::mul(int factor1, int factor2)
{
m_lastResult = factor1 * factor2;
return true;
bool DeleteMe::mul(int factor1, int factor2) {
m_lastResult = factor1 * factor2;
return true;
}

bool DeleteMe::div(int dividend, int divisor)
{
if (divisor == 0)
{
m_lastResult = 0;
return false;
}
bool DeleteMe::div(int dividend, int divisor) {
if (divisor == 0) {
m_lastResult = 0;
return false;
}

m_lastResult = dividend / divisor;
return true;
m_lastResult = dividend / divisor;
return true;
}

int DeleteMe::get_last_result()
{
return m_lastResult;
int DeleteMe::get_last_result() {
return m_lastResult;
}
Loading