forked from MuUJa/ST-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 694d735
Showing
13 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: GHA-frac-Release | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install gtest manually | ||
run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && ls -l lib && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a | ||
- uses: actions/checkout@v1 | ||
- name: configure | ||
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" .. | ||
- name: make | ||
run: cd build && make | ||
- name: Run Test | ||
run: /home/runner/work/ST-1/ST-1/build/test/ST-1.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required (VERSION 3.10.2) | ||
project (ST-1) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -g") | ||
|
||
|
||
set(tool_dest "bin") | ||
set(lib_dest "lib") | ||
set(include_dest "include/") | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# ST-1 UNIT-тестирование с использованием Googletest (C++) (1) | ||
|
||
|
||
 | ||
 | ||
|
||
Срок выполнения задания: | ||
|
||
<!--- **до 26.02.23**  --> | ||
|
||
|
||
## Задание | ||
|
||
> Написать прототип библиотеки для работы с простыми (prime) числами. | ||
**Состав проекта** | ||
|
||
```C++ | ||
- bool checkPrime(uint64_t value) - проверка числа на простоту. | ||
- uint64_t nPrime(uint64_t n) - нахождение n-ого простого числа (в ряду). | ||
- uint64_t nextPrime(uint64_t value) - нахождение ближайшего следующего простого числа к value. | ||
- uint64_t sumPrime(uint64_t hbound) - сумма всех чисел до hbound (не включая его) | ||
``` | ||
## Пояснение | ||
Требуется написать несколько функций на языках С/С++, выполняющих поставленные задачи и протестировать работу этих функций с помощью модульных тестов | ||
Функции должны иметь заданную сигнатуру и располагаться в файле **alg.cpp**: | ||
```C++ | ||
bool checkPrime(uint64_t value) { | ||
} | ||
``` | ||
|
||
- **value** - проверяемое значение | ||
|
||
Функция возвращает **true**, если число **value** простое и **false** в противном случае. | ||
|
||
|
||
```C++ | ||
uint64_t nPrime(uint64_t n) { | ||
|
||
} | ||
``` | ||
- **n** - n-ое число в ряду. Например, 2 - первое простое число, 3 - второе, 5 - третье... | ||
Функция возвращает найденное простое число. | ||
```C++ | ||
uint64_t nextPrime(uint64_t value) { | ||
} | ||
``` | ||
|
||
- **value** - исходное число, начиная с которого мы ищем ближайшее простое. Само **value** при поиске не учитывается. Например, для числа 4 следующим простым будет 5, а для 11 следующим простым будет 13. | ||
|
||
Функция возвращает найденное простое число. | ||
|
||
```C++ | ||
uint64_t sumPrime(uint64_t hbound) { | ||
|
||
} | ||
``` | ||
Функция находит сумму простых чисел до **hbound** (сама граница в сумму не включается) | ||
Функция возвращает сумму простых чисел. | ||
Функции должны располагаться в файле **src/alg.cpp**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Здесь размещаются заголовочные файлы всех задач | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2022 NNTU-CS | ||
#ifndef INCLUDE_ALG_H_ | ||
#define INCLUDE_ALG_H_ | ||
#include <cstdint> | ||
|
||
bool checkPrime(uint64_t value); | ||
uint64_t nPrime(uint64_t n); | ||
uint64_t nextPrime(uint64_t value); | ||
uint64_t sumPrime(uint64_t hbound); | ||
|
||
#endif // INCLUDE_ALG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
set(header_path "${${PROJECT_NAME}_SOURCE_DIR}/include") | ||
set(header ${header_path}/alg.h) | ||
set(src alg.cpp) | ||
|
||
add_library(${PROJECT_NAME} SHARED | ||
${header} | ||
${src}) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC ${CMAKE_CURRENT_BINARY_DIR} | ||
${${PROJECT_NAME}_SOURCE_DIR}/include) | ||
target_link_libraries(${PROJECT_NAME} | ||
pthread) | ||
|
||
add_executable(${PROJECT_NAME}.info main.cpp) | ||
target_include_directories(${PROJECT_NAME}.info | ||
PUBLIC ${CMAKE_CURRENT_BINARY_DIR} | ||
${${PROJECT_NAME}_SOURCE_DIR}/include) | ||
target_link_libraries(${PROJECT_NAME}.info | ||
${PROJECT_NAME}) | ||
|
||
|
||
install(TARGETS ${PROJECT_NAME} | ||
LIBRARY DESTINATION "${lib_dest}" | ||
ARCHIVE DESTINATION "${lib_dest}" | ||
COMPONENT library) | ||
install(TARGETS ${PROJECT_NAME}.info | ||
RUNTIME DESTINATION "${tool_dest}" | ||
COMPONENT library) | ||
install(FILES ${header} DESTINATION "${include_dest}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Здесь размещаются исходные файлы всех задач | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2022 NNTU-CS | ||
#include <cstdint> | ||
#include "alg.h" | ||
|
||
|
||
bool checkPrime(uint64_t value) { | ||
// вставьте код функции | ||
} | ||
|
||
uint64_t nPrime(uint64_t n) { | ||
// вставьте код функции | ||
} | ||
|
||
uint64_t nextPrime(uint64_t value) { | ||
// вставьте код функции | ||
} | ||
|
||
uint64_t sumPrime(uint64_t hbound) { | ||
// вставьте код функции | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2022 NNTU-CS | ||
#include "alg.h" | ||
|
||
int main() { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2020 GHA Test Team | ||
|
||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_executable(${PROJECT_NAME}.test | ||
AllTests.cpp | ||
tests.cpp) | ||
target_link_libraries(${PROJECT_NAME}.test | ||
${PROJECT_NAME} gtest pthread) | ||
target_compile_definitions(${PROJECT_NAME}.test | ||
PRIVATE TEST_DIR="${CMAKE_CURRENT_LIST_DIR}/test") | ||
|
||
install(TARGETS ${PROJECT_NAME}.test | ||
DESTINATION "${tool_dest}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Здесь размещаются тесты для всех задач | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
#include <gtest/gtest.h> | ||
#include <cstdint> | ||
#include "alg.h" | ||
|
||
|