Skip to content

Add ut to project and create tests for each of the algorithms. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
491ed2f
copied the .gitignore from j project.
Sebanisu Mar 7, 2021
fe92c89
set library to c++20
Sebanisu Mar 8, 2021
282e48b
create tests
Sebanisu Mar 8, 2021
493f5c4
Added compiler-warnings and rearranged files. added a couple tests
Sebanisu Mar 8, 2021
6119937
east const and added some tests reworded test names. changed custom t…
Sebanisu Mar 8, 2021
525554c
instead of baking in a initializer list of numbers I wrote a consteva…
Sebanisu Mar 8, 2021
6adbf47
copied .clang-format to project from j. ran clang format on algorithm…
Sebanisu Mar 8, 2021
865d822
Create CONTRIBUTING.md
Sebanisu Mar 8, 2021
c39ee59
I guess there is supposed to be a NAME and COMMAND word on this .
Sebanisu Mar 8, 2021
0c9c9d1
enable_testing() needs to be in the root CMakeLists.txt or included v…
Sebanisu Mar 8, 2021
585083b
removed note about command not working as it's working now.
Sebanisu Mar 8, 2021
3fdc814
remove command #
Sebanisu Mar 8, 2021
7e356cf
add command for verbose output from tests
Sebanisu Mar 8, 2021
ced0dcd
add a custom executable name to algorithm_test
Sebanisu Mar 8, 2021
cf24ca0
Create appveyor.yml
Sebanisu Mar 8, 2021
eaf9897
you have to use the PRIVATE keyword for each library you include
Sebanisu Mar 9, 2021
100f21f
fixed compiler warnings.
Sebanisu Mar 10, 2021
cb5b84d
Should probably be private, though for executables it probably doesn'…
Sebanisu Mar 10, 2021
7f9019a
herwinw pointed out we don't need to build anything.
Sebanisu Mar 10, 2021
586b751
remove j .gitignore entries.
Sebanisu Mar 10, 2021
3150850
wrap tests in if statement per "modern-cmake"
Sebanisu Mar 10, 2021
330ae6e
Setting target specific settings instead of global
Sebanisu Mar 10, 2021
177327d
appveyor to now build on visual studio 2019
Sebanisu Mar 10, 2021
6a0eaa2
add clang to CI
Sebanisu Mar 11, 2021
2f097cb
clang failed because it lacked <ranges> and <concepts>
Sebanisu Mar 11, 2021
921be4a
fix clang? removed ranges.
Sebanisu Mar 11, 2021
cf4cc51
custom iota to fix clang?
Sebanisu Mar 11, 2021
810928c
just realized ninja command should be used to build msvc.
Sebanisu Mar 11, 2021
be70802
Revert "just realized ninja command should be used to build msvc."
Sebanisu Mar 11, 2021
a7b6141
add Windows instructions to the Contributing.md
Sebanisu Mar 11, 2021
70e393a
add how to swap between compilers on linux.
Sebanisu Mar 11, 2021
f386da2
formatted the md
Sebanisu Mar 11, 2021
8188728
reformated the end of this line.
Sebanisu Mar 11, 2021
3f018b0
created add_test_common function to cmake.
Sebanisu Mar 11, 2021
a32a43f
added /wd4505
Sebanisu Mar 11, 2021
a35d875
comment out warning suppression
Sebanisu Mar 16, 2021
62507dc
change found to any_of in the test.
Sebanisu Mar 18, 2021
b6488b3
clang 12 build script
Sebanisu Mar 22, 2021
3ac57bd
move project_warnings library into the .cmake file and added clang co…
Sebanisu Mar 22, 2021
bd516ac
add GIT_REMOTE_UPDATE_STRATEGY
Sebanisu Mar 29, 2021
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
155 changes: 155 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
# Refer to the following link for the explanation of each params:
# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
# This is deprecated
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
# disabling the below splits, else, they'll just add to the vertical length of source files!
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# Kept the below 2 to be the same as `IndentWidth` to keep everything uniform
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
# Enabling comment reflow causes doxygen comments to be messed up in their formats!
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
# Be consistent with indent-width, even for people who use tab for indentation!
TabWidth: 3
UseTab: Never
135 changes: 131 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,131 @@
#clion build folders.
cmake-build-*/*
#clion settings.
.idea/*
#vscode
.vscode/

# unix
*.o
*.so
!asm/*.o

# windows - most output files go to %userprofile%\jbld\jout
# some end up in the project folder and are marked here
# sometimes entire project subfolders are created that should not be in repo
*.sdf
*.opensdf
*.suo
*.ilk
*.pdb
*.exp

# windows - need to run with different versions of vs
# following files are in repo for vs2013
# but are not pushed to avoid getting unwanted user specific changes
# clone will have to copy from .template files to work
*.sln*
*.vcxproj*
!*.template
.vs/

# mac
.DS_Store

#android
android/libs/
android/obj/
android/jni/jsrc
android/jni/clapack
android/jni/pcre
android/jni/pcre2
android/jni/tsdll
android/jni/hostdefs
android/jni/netdefs
clapack/
pcre/

release
/test/temp.ijs

# build folders
out/
build/
bin/
make2/

# clion's cmake creates cmake-build-release, cmake-build-debug, etc...
cmake-build-*/
# clion's settings folder. keep or not up to you. can be useful for spellcheck etc.
.idea

# QtCreator config files
# A listing of all the files included in the project
*.files

# Include directories
*.includes

# Project configuration settings like predefined Macros
*.config

# Qt Creator settings
*.creator

# User project settings
*.creator.user*

# Qt Creator backups
*.autosave

# Flags for Clang Code Model
*.cxxflags
*.cflags

# Meson Build System files
# subproject directories
/subprojects/*
!/subprojects/*.wrap

# Meson Directories
meson-logs
meson-private

# Meson Files
meson_benchmark_setup.dat
meson_test_setup.dat
sanitycheckcpp.cc # C++ specific
sanitycheckcpp.exe # C++ specific

# Ninja
build.ninja
.ninja_deps
.ninja_logs

# Misc
compile_commands.json
# Prerequisites
*.d

# Precompiled Headers
*.gch
*.pch

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# doxygen
docs/doxygen
docs/latex
docs/html
docs/make.bat
docs/xml
docs/_build
docs/Makefile

#python in clion
venv/*
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.18)
project(An-Algorithm-Library C CXX)

set(CMAKE_CXX_STANDARD 17) ## Supported values are 98, 11, 14, 17, and 20.
set(CMAKE_CXX_STANDARD_REQUIRED ON) ## the value of the CXX_STANDARD target property is treated as a requirement
set(CMAKE_CXX_EXTENSIONS OFF) ## on g++ this ensures: -std=c++11 and not -std=gnu++11
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) ## automatically create a module definition (.def) file with all global
## symbols found in the input .obj files for a SHARED library on Windows.

add_subdirectory(src)
add_subdirectory(src)
# see https://cliutils.gitlab.io/modern-cmake/chapters/testing.html
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif ()
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND BUILD_TESTING)
add_subdirectory(tests)
endif ()
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
### Getting Started & Building:

1. Prerequisites:
* CMake version 3.18.0+ -> Ubuntu systems seem to have a problem getting the latest version, please build from
sources or use another package such as snap.
* [Ubuntu CMake update instructions](https://apt.kitware.com/)
* Ninja
2. Checkout the repository:
```sh
git clone https://github.com/codereport/An-Algorithm-Library.git
```

#### Linux or Windows w/ Clang

0. Switch between GCC or Clang, on linux:
* GCC
```sh
export CC=gcc
export CXX=g++
```
* Clang
```sh
export CC=clang
export CXX=clang++
```
1. Run cmake:
```sh
cd An-Algorithm-Library
mkdir build
cmake -G "Ninja Multi-Config" -B build
```
2. Run tests:
```sh
ninja -C build test
```
* For more verbose output:

```sh
# On linux you can combine these lines with &&
ninja -C build
cd build
ctest -C debug --verbose
cd ..
```

#### Windows MSVC

1. Run cmake:
```sh
cd An-Algorithm-Library
mkdir build
cmake -G "Visual Studio 16 2019" -B build
```
2. Run tests:
* For more verbose output:
```sh
MSBuild build\ALL_BUILD.vcxproj
cd build
ctest -C debug --verbose
cd ..
```
Loading