This repository was archived by the owner on Jan 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
[task_02] Lab2 #295
Open
gr1frykt
wants to merge
22
commits into
brstu:main
Choose a base branch
from
gr1frykt:task_02
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[task_02] Lab2 #295
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
180fa57
lab2 done
gr1frykt 4c64e77
Merge branch 'main' into task_02
gr1frykt 43c17c8
Update CMakeLists.txt
gr1frykt 1e8bd52
Update and rename linear.cpp to linear1.cpp
gr1frykt 142bf68
Update CMakeLists.txt
gr1frykt 78855a1
Update CMakeLists.txt
gr1frykt c5929b8
Update CMakeLists.txt
gr1frykt 4d2d9af
Update and rename linear.h to Linear.h
gr1frykt ce1a3d7
Update linear1.cpp
gr1frykt e3024b5
Update otis2.cpp
gr1frykt d338735
Update CMakeLists.txt
gr1frykt 2fd7012
Update test.cpp
gr1frykt 0b75113
Update Linear.h
gr1frykt 99df10d
Update linear1.cpp
gr1frykt 8a62189
changed code
gr1frykt d424d8b
Merge branch 'main' into task_02
gr1frykt 34edddd
Merge branch 'main' into task_02
Lictwin abe108a
Merge branch 'main' into task_02
Lictwin 3027b76
Merge branch 'main' into task_02
Lictwin 91a08a1
Update CMakeLists.txt
gr1frykt d9f8449
Merge branch 'main' into task_02
gr1frykt ad123cc
Merge branch 'main' into task_02
Lictwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,40 @@ | ||
| <p align="center"> Министерство образования Республики Беларусь</p> | ||
| <p align="center">Учреждение образования</p> | ||
| <p align="center">“Брестский Государственный технический университет”</p> | ||
| <p align="center">Кафедра ИИТ</p> | ||
| <br><br><br><br><br><br><br> | ||
| <p align="center">Лабораторная работа №2</p> | ||
| <p align="center">По дисциплине “Общая теория интеллектуальных систем”</p> | ||
| <p align="center">Тема: “Написание модульных тестов для программы моделирования температуры”</p> | ||
| <br><br><br><br><br> | ||
| <p align="right">Выполнил:</p> | ||
| <p align="right">Студент 2 курса</p> | ||
| <p align="right">Группы ИИ-27</p> | ||
| <p align="right">Гридчин А.В.</p> | ||
| <p align="right">Проверил:</p> | ||
| <p align="right">Дворанинович Д.А.</p> | ||
| <br><br><br><br><br> | ||
| <p align="center">Брест 2025</p> | ||
|
|
||
| # Общее задание # | ||
| 1. Использовать следующий фреймворк для модульного тестирования - [Google Test](https://google.github.io/googletest/). | ||
| 2. Написать модульные тесты для основных функций программы. Разместить тесты в каталоге: **trunk\ii0xxyy\task_02\test**. | ||
| 3. Исходный код модифицированной программы разместить в каталоге: **trunk\ii0xxyy\task_02\src**. | ||
| 4. В файле `readme.md` отразить количество написанных тестов и процент покрытия кода тестами (использовать любой инструмент для анализа покрытия, например, [gcovr](https://gcovr.com/en/stable/)). | ||
|
|
||
| ## Задание 2.## | ||
|
gr1frykt marked this conversation as resolved.
|
||
| В ходе выполнения было написано три теста. Было написано три теста для функции linear. Покрытие программы составляет 67%. Замер производился с помощью программы OpenCppCoverage(https://github.com/OpenCppCoverage/OpenCppCoverage/releases). | ||
| [==========] Running 3 tests from 1 test suite. | ||
| [----------] Global test environment set-up. | ||
| [----------] 3 tests from Test | ||
| [ RUN ] Test.linearr | ||
| [ OK ] Test.linearr (0 ms) | ||
| [ RUN ] Test.linearr2 | ||
| [ OK ] Test.linearr2 (0 ms) | ||
| [ RUN ] Test.linearr3 | ||
| [ OK ] Test.linearr3 (0 ms) | ||
| [----------] 3 tests from Test (2 ms total) | ||
|
|
||
| [----------] Global test environment tear-down | ||
| [==========] 3 tests from 1 test suite ran. (4 ms total) | ||
| [ PASSED ] 3 tests. | ||
This file contains hidden or 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 @@ | ||
| cmake_minimum_required (VERSION 3.5) | ||
| project (task_02_ii02704) | ||
|
|
||
| add_library(linear_ii02704 | ||
| linear1.cpp) | ||
|
|
||
| add_executable (ii02704_task2 | ||
| otis2.cpp) | ||
|
|
||
| target_link_libraries(ii02704_task2 PRIVATE linear_ii02704) |
This file contains hidden or 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,18 @@ | ||
| #ifndef LINE_H | ||
| #define LINE_H | ||
|
gr1frykt marked this conversation as resolved.
|
||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| struct Params | ||
| { | ||
| int k; | ||
|
gr1frykt marked this conversation as resolved.
|
||
| std::vector<double> y; | ||
| std::vector<double> u; | ||
| double a; | ||
|
gr1frykt marked this conversation as resolved.
|
||
| double b; | ||
| }; | ||
|
gr1frykt marked this conversation as resolved.
|
||
|
|
||
| void input(Params &s); | ||
| void linear(Params &s, const int& place); | ||
|
gr1frykt marked this conversation as resolved.
|
||
|
|
||
| #endif | ||
This file contains hidden or 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,31 @@ | ||
| #include "Linear.h" | ||
| #include <iostream> | ||
|
|
||
| using namespace std; | ||
|
|
||
| void input(Params &s) { | ||
| cout << "Enter amount of iterations: "; | ||
| cin >> s.k; | ||
| s.u.resize(s.k + 1, 0); | ||
| s.y.resize(s.k + 1, 0); | ||
| cout << "\nEnter temperature: "; | ||
| cin >> s.y.at(0); | ||
| for (auto& warm : s.u) { | ||
| cout << "\nEnter warm: "; | ||
| cin >> warm; | ||
| } | ||
|
|
||
| cout << "Enter const a: "; | ||
|
|
||
| cin >> s.a; | ||
|
|
||
| cout << "Enter const b: "; | ||
|
|
||
| cin >> s.b; | ||
|
|
||
| } | ||
| void linear(Params &s, const int& place) { | ||
| if(s.k >= 0){ | ||
| s.y.at(place + 1) = s.a * s.y.at(place) + s.b * s.u.at(place); | ||
| } | ||
| } |
This file contains hidden or 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,19 @@ | ||
| #include <iostream> | ||
|
gr1frykt marked this conversation as resolved.
|
||
| #include <vector> | ||
| #include "Linear.h" | ||
|
|
||
| using namespace std; | ||
|
|
||
|
|
||
| int main() | ||
| { | ||
| Params p; | ||
| input(p); | ||
| for (int i = 0; i < p.k; i++) { | ||
| linear(p,i); | ||
| } | ||
| for (auto n : p.y) { | ||
| cout << n << endl; | ||
| } | ||
| return 0; | ||
| } | ||
This file contains hidden or 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,46 @@ | ||
| cmake_minimum_required(VERSION 3.5) | ||
| project(task_02_ii02704_test) | ||
|
|
||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") | ||
|
|
||
|
|
||
| include(FetchContent) | ||
| FetchContent_Declare( | ||
| googletest | ||
| URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip | ||
| DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
| ) | ||
| # For Windows: Prevent overriding the parent project's compiler/linker settings | ||
| set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
| FetchContent_MakeAvailable(googletest) | ||
|
|
||
| enable_testing() | ||
|
|
||
|
|
||
| add_executable( | ||
| ${CMAKE_PROJECT_NAME} | ||
| test.cpp | ||
|
|
||
| ../src/linear1.cpp | ||
| ../src/Linear.h | ||
| ) | ||
| target_link_libraries( | ||
| ${CMAKE_PROJECT_NAME} | ||
| PRIVATE | ||
| gtest | ||
| gtest_main | ||
| gmock | ||
| ) | ||
|
|
||
|
|
||
| target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE --coverage -g -O0) | ||
| target_link_options(${CMAKE_PROJECT_NAME} PRIVATE --coverage) | ||
|
|
||
|
|
||
| include(GoogleTest) | ||
| gtest_discover_tests(${CMAKE_PROJECT_NAME}) |
This file contains hidden or 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,45 @@ | ||
| #include "gtest/gtest.h" | ||
| #include "../src/Linear.h" | ||
| TEST(Test, linearr) { | ||
|
gr1frykt marked this conversation as resolved.
|
||
| double res; | ||
| Params p; | ||
| p.y.resize(2, 0); | ||
| p.u.resize(2, 0); | ||
| p.k = 2; | ||
| p.y[0] = 13; | ||
| p.u[0] = 1.3; | ||
|
gr1frykt marked this conversation as resolved.
|
||
| p.a = 2.3; | ||
| p.b = 5.6; | ||
| linear(p,0); | ||
| res = p.y[1]; | ||
| EXPECT_NEAR(res, 37.18, 0.01); | ||
|
gr1frykt marked this conversation as resolved.
|
||
| } | ||
| TEST(Test, linearr2) { | ||
|
gr1frykt marked this conversation as resolved.
|
||
| double res; | ||
| Params p; | ||
| p.y.resize(2, 0); | ||
| p.u.resize(2, 0); | ||
| p.k = 2; | ||
| p.y[0] = 2.6; | ||
| p.u[0] = 3.5; | ||
| p.a = 14.7; | ||
| p.b = 5.6; | ||
| linear(p,0); | ||
| res = p.y[1]; | ||
| EXPECT_NEAR(res, 57.82, 0.01); | ||
| } | ||
|
|
||
| TEST(Test, linearr3) { | ||
|
gr1frykt marked this conversation as resolved.
gr1frykt marked this conversation as resolved.
|
||
| double res; | ||
| Params p; | ||
| p.y.resize(2, 0); | ||
| p.u.resize(2, 0); | ||
| p.k = 2; | ||
| p.y[0] = 0.8; | ||
| p.u[0] = 9.6; | ||
| p.a = 12.3; | ||
| p.b = 7.3; | ||
| linear(p,0); | ||
| res = p.y[1]; | ||
| EXPECT_NEAR(res, 79.92, 0.01); | ||
|
gr1frykt marked this conversation as resolved.
|
||
| } | ||
|
gr1frykt marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.