Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
4efb806
fill repo correctly
BorisKoz Mar 10, 2021
51c488c
ver.2
BorisKoz Mar 10, 2021
16088c6
added simple gtest. plan on adding more. switching to travis
BorisKoz Mar 10, 2021
d38a676
create a correct travis iml
BorisKoz Mar 10, 2021
bbc719c
Update .travis.yml
BorisKoz Mar 10, 2021
80ac820
Update README.md
BorisKoz Mar 10, 2021
5b79a2f
Update .travis.yml
BorisKoz Mar 10, 2021
2336041
cmake v lower
BorisKoz Mar 10, 2021
2d62b83
Update .travis.yml
BorisKoz Mar 10, 2021
f323962
Merge branch 'HW-1' of https://github.com/BorisKoz/cpp_2021 into HW-1
BorisKoz Mar 10, 2021
d74186f
Update README.md
BorisKoz Mar 10, 2021
678ab3b
Update .travis.yml
BorisKoz Mar 10, 2021
7c26f21
Update .travis.yml
BorisKoz Mar 10, 2021
209750d
Update .travis.yml
BorisKoz Mar 10, 2021
7147352
Update README.md
BorisKoz Mar 10, 2021
2e7c0f2
Update .travis.yml
BorisKoz Mar 10, 2021
65654fd
resolving the segfault
BorisKoz Mar 10, 2021
c7bf8c5
Merge branch 'HW-1' of https://github.com/BorisKoz/cpp_2021 into HW-1
BorisKoz Mar 10, 2021
97cf7de
fixed stupid mistake of wrong names
BorisKoz Mar 10, 2021
759d538
Update .travis.yml
BorisKoz Mar 10, 2021
3d01538
fixed mleaks
BorisKoz Mar 10, 2021
130b07b
Merge branch 'HW-1' of https://github.com/BorisKoz/cpp_2021 into HW-1
BorisKoz Mar 10, 2021
3ce1058
Update .travis.yml
BorisKoz Mar 10, 2021
1262ffd
Update .travis.yml
BorisKoz Mar 10, 2021
0106eb1
Update .travis.yml
BorisKoz Mar 10, 2021
537e61e
added flags for codecov
BorisKoz Mar 10, 2021
d9f08b2
Update .travis.yml
BorisKoz Mar 10, 2021
472b346
Update README.md
BorisKoz Mar 10, 2021
7bc2cde
changed test names & structure
BorisKoz Mar 11, 2021
be813e8
added 97% codecov
BorisKoz Mar 11, 2021
57ede38
corrected tests execute dir
BorisKoz Mar 11, 2021
5e88e41
corrected cpplint
BorisKoz Mar 11, 2021
add27d5
added tests cpplint
BorisKoz Mar 11, 2021
8ea7abb
added terminal input. running tests on valgrind on remote to check ir
BorisKoz Mar 11, 2021
aacd6df
valgrind test look src
BorisKoz Mar 11, 2021
b4eabcb
valgrind test 2 look src
BorisKoz Mar 11, 2021
84b0212
seems like no leaks
BorisKoz Mar 11, 2021
54caede
next try
BorisKoz Mar 11, 2021
cfffa66
fixed cpplint
BorisKoz Mar 11, 2021
72828b7
search is now in another func, with gtest. added cppcheck tags
BorisKoz Mar 11, 2021
2a8e204
static complete
BorisKoz Mar 11, 2021
bd2c90b
valgrind is fun
BorisKoz Mar 11, 2021
2fb0d49
Update .travis.yml
BorisKoz Mar 11, 2021
381fbc5
valgrind is so FUN
BorisKoz Mar 11, 2021
39e8f28
Merge branch 'HW-1' of https://github.com/BorisKoz/cpp_2021 into HW-1
BorisKoz Mar 11, 2021
3f4db2a
found uninitialised float
BorisKoz Mar 11, 2021
fa5ee89
found uninitialised float
BorisKoz Mar 11, 2021
4bf2d11
vagrind for the win
BorisKoz Mar 11, 2021
6ec3e6d
fixed travis
BorisKoz Mar 11, 2021
46109a8
fixed travis again
BorisKoz Mar 11, 2021
3673d77
until I understand how to < with valgr in is 255, so removed
BorisKoz Mar 11, 2021
da8519b
255 was because of code error, lol. remade
BorisKoz Mar 11, 2021
474e7e9
fixed almost all. to travis
BorisKoz Mar 16, 2021
aee11c9
fixed minor leak error
BorisKoz Mar 16, 2021
ce3ace4
added all to one Cmake
BorisKoz Mar 16, 2021
2796675
error in Cmake fixed
BorisKoz Mar 16, 2021
d7d9f88
fixed vg, added logic to diff header
BorisKoz Mar 16, 2021
64d6400
fixed travis misspell and cpplint
BorisKoz Mar 16, 2021
bcb8566
fixed newline
BorisKoz Mar 16, 2021
f90f31c
fix to new reviews
BorisKoz Mar 17, 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
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage:
status:
patch:
default:
target:80%
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

# CMake
project/build/
CMakeFiles/
CMakeCache.txt
cmake-build-debug/
cmake-build-debug-coverage/
*.cmake


.idea/
.DS_Store

29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
dist: focal

language: c

os: linux

compiler: gcc

install:
- sudo apt-get install valgrind
- sudo apt-get install clang
- sudo apt-get install cppcheck
- sudo pip install cpplint

script:
- cd project/
- mkdir build
- cd build
- cmake ..
- make clean && make
- cppcheck --inconclusive --enable=all --language=c ../include/*.h ../src/*.c
- cpplint ../include/*.h ../src/*.c ../tests/*.cpp
- valgrind --leak-check=full --track-origins=yes ./main.out ../db.txt ../find.txt < ../find.txt
- valgrind --leak-check=full --track-origins=yes ./cars_tests



after_success:
- bash <(curl -s https://codecov.io/bash)
4 changes: 4 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
filter=-legal/copyright
filter=-build/include_subdir
filter=-build/include
filter=-readability/casting
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# cpp_2021


[![Build Status](https://travis-ci.com/BorisKoz/cpp_2021.svg?branch=HW-1)](https://travis-ci.com/BorisKoz/cpp_2021)

[![codecov](https://codecov.io/gh/BorisKoz/cpp_2021/branch/HW-1/graph/badge.svg?token=QT0UXBZB7L)](https://codecov.io/gh/BorisKoz/cpp_2021)


# Вариант #4
Создать структуру для хранения характеристик автомобилей: мощности двигателя, скорости, расхода топлива, формы кузова и модели. Составить с ее использованием программу поиска модели автомобиля, характеристики которой наиболее удовлетворяют запросу.

# Требования к оформлению:
Программа должна быть реализована на языке C и работать для произвольных наборов входных данных (в том числе и ошибочных), вводимых пользователем с клавиатуры. Должна быть выполнена грамотная декомпозиция на функции и файлы.
Помимо самой программы необходимо:
– разработать набор юнит-тестов, проверяющих корректную работу реализованных функций. Обеспечить максимальное покрытие исходного кода тестами;
– оформить задачу в виде Merge Request отдельной ветки в основную ветку проекта.
Внимание: в основной ветке проекта никакого кода быть не должно!
– развернуть CI, в рамках которого автоматизировать сборку проекта, прохождение юнит-тестов под valgrind, генерацию отчёта о покрытии кода тестами, линтера и статического анализатора исходного кода;
– после прохождения всех проверок необходимо отправить код на ревью своему преподавателю;
– ревью - процесс итерационный. До наступления дедлайна можно проходить несколько итераций, улучшая свою оценку. Решения после дедлайна не принимаются;
Binary file added project/.DS_Store
Binary file not shown.
45 changes: 45 additions & 0 deletions project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.15)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет продуктовой цели, только тестовая.

project(cars)

configure_file(CMakeLists.txt.in
googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )

add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build)

set(CMAKE_C_FLAGS "-pedantic -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "-pedantic -fprofile-arcs -ftest-coverage")

enable_testing()


include_directories("${PROJECT_SOURCE_DIR}/include")


file(GLOB prod_sources
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/src/cars.c"
"${PROJECT_SOURCE_DIR}/src/main.c")

add_executable(main.out ${prod_sources})

file(GLOB test_sources "${PROJECT_SOURCE_DIR}/src/*.c")
list(REMOVE_ITEM test_sources "${PROJECT_SOURCE_DIR}/src/main.c")

file(GLOB tests "${PROJECT_SOURCE_DIR}/tests/*.cpp")
list(REMOVE_ITEM tests "${PROJECT_SOURCE_DIR}/tests/main.cpp")

foreach(file ${tests})
set(name)
get_filename_component(name ${file} NAME_WE)
add_executable("${name}_tests"
${test_sources}
${file}
"${PROJECT_SOURCE_DIR}/tests/main.cpp")
target_link_libraries("${name}_tests" gtest_main)
add_test(NAME ${name} COMMAND "${name}_tests")
endforeach()
15 changes: 15 additions & 0 deletions project/CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.15)

project(googletest-download NONE)

include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.1
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
227 changes: 227 additions & 0 deletions project/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.19

# Default target executed when no arguments are given to make.
default_target: all

.PHONY : default_target

# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:


#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:


# Disable VCS-based implicit rules.
% : %,v


# Disable VCS-based implicit rules.
% : RCS/%


# Disable VCS-based implicit rules.
% : RCS/%,v


# Disable VCS-based implicit rules.
% : SCCS/s.%


# Disable VCS-based implicit rules.
% : s.%


.SUFFIXES: .hpux_make_needs_suffix_list


# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s

#Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:

.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.19.6/bin/cmake

# The command to remove a file.
RM = /usr/local/Cellar/cmake/3.19.6/bin/cmake -E rm -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/boriskozuro/Desktop/tp_c_2021/project

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/boriskozuro/Desktop/tp_c_2021/project

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/local/Cellar/cmake/3.19.6/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache

.PHONY : rebuild_cache/fast

# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/local/Cellar/cmake/3.19.6/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache

.PHONY : edit_cache/fast

# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /Users/boriskozuro/Desktop/tp_c_2021/project/CMakeFiles /Users/boriskozuro/Desktop/tp_c_2021/project//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /Users/boriskozuro/Desktop/tp_c_2021/project/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean

.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named test1

# Build rule for target.
test1: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test1
.PHONY : test1

# fast build rule for target.
test1/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/build
.PHONY : test1/fast

src/cars.o: src/cars.c.o

.PHONY : src/cars.o

# target to build an object file
src/cars.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/cars.c.o
.PHONY : src/cars.c.o

src/cars.i: src/cars.c.i

.PHONY : src/cars.i

# target to preprocess a source file
src/cars.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/cars.c.i
.PHONY : src/cars.c.i

src/cars.s: src/cars.c.s

.PHONY : src/cars.s

# target to generate assembly for a file
src/cars.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/cars.c.s
.PHONY : src/cars.c.s

src/main.o: src/main.c.o

.PHONY : src/main.o

# target to build an object file
src/main.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/main.c.o
.PHONY : src/main.c.o

src/main.i: src/main.c.i

.PHONY : src/main.i

# target to preprocess a source file
src/main.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/main.c.i
.PHONY : src/main.c.i

src/main.s: src/main.c.s

.PHONY : src/main.s

# target to generate assembly for a file
src/main.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/test1.dir/build.make CMakeFiles/test1.dir/src/main.c.s
.PHONY : src/main.c.s

# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... test1"
@echo "... src/cars.o"
@echo "... src/cars.i"
@echo "... src/cars.s"
@echo "... src/main.o"
@echo "... src/main.i"
@echo "... src/main.s"
.PHONY : help



#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

4 changes: 4 additions & 0 deletions project/db.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
150 200 2 Renault_Logan Jeep
100 100 2 Toyota_Camry Sedan
100 100 1 Toyota_Camry Sedan
100 120 2 Renault_Sanderas Sedan
1 change: 1 addition & 0 deletions project/find.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100 100 1 Toyota_Camry Sedan
Loading