-
Notifications
You must be signed in to change notification settings - Fork 22
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
Григорий Севергин
committed
Oct 31, 2024
1 parent
6821b20
commit 244cd7a
Showing
7 changed files
with
146 additions
and
1 deletion.
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,31 @@ | ||
name: Urfu Testing CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
task1: | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: lifestyle288/urfucpp:latest | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
options: --name main-container | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install dependecies | ||
run: | | ||
cd task1 | ||
cp -R /app/tests/task1 tests | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j4 | ||
- name: Run tests | ||
run: cd task1/build && ctest |
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 @@ | ||
build | ||
tests | ||
Dockerfile | ||
test.sh |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
# Urfu-Advanced-Cpp | ||
# Как работать с репозиторием | ||
- Форкаем реп | ||
- После выполнения задания нужно сделать pull request на преподавателя со всеми пройденными тестами | ||
- Тестирование срабатывает при любом пуше в реп, а так же при создании pull request |
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,15 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
|
||
project(matrix) | ||
|
||
find_package(Boost COMPONENTS unit_test_framework REQUIRED) | ||
if (Boost_FOUND) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
endif (Boost_FOUND) | ||
|
||
add_library(matrix STATIC matrix.cpp) | ||
|
||
if (Boost_FOUND) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif (Boost_FOUND) |
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,26 @@ | ||
# Класс Matrix | ||
|
||
#### Требуется реализовать интерфейс: | ||
|
||
```c++ | ||
class Matrix | ||
{ | ||
public: | ||
Matrix() = default; | ||
Matrix(int numRows, int numCols); | ||
|
||
void Reset(int numRows, int numCols); | ||
int& At(int row, int col); | ||
const int& At(int row, int col) const; | ||
int GetRows() const; | ||
int GetCols() const; | ||
|
||
bool operator==(const Matrix& m2); | ||
bool operator!=(const Matrix& m2); | ||
Matrix operator+(const Matrix& m2); | ||
}; | ||
``` | ||
|
||
- методы At должны выбрасывать исключение std::out_of_range, если ячейка, которая в него передана выходит за границы матрицы | ||
- если в метод Reset передали число колонок или столбцов равное 0, то оставляем объект в консистентном состоянии, зануляя количество столбцов и количество строк | ||
- если мы пытаемся сложить 2 матрицы разных размеров, то должно выбрасываться исключение std::invalid_argument |
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,48 @@ | ||
#include "matrix.hpp" | ||
|
||
#include <stdexcept> | ||
|
||
Matrix::Matrix(int numRows, int numCols) | ||
{ | ||
// your implementation here | ||
} | ||
|
||
void Matrix::Reset(int numRows, int numCols) | ||
{ | ||
// your implementation here | ||
} | ||
|
||
int& Matrix::At(int row, int col) | ||
{ | ||
// your implementation here | ||
} | ||
|
||
const int& Matrix::At(int row, int col) const | ||
{ | ||
// your implementation here | ||
} | ||
|
||
int Matrix::GetRows() const | ||
{ | ||
// your implementation here | ||
} | ||
|
||
int Matrix::GetCols() const | ||
{ | ||
// your implementation here | ||
} | ||
|
||
bool Matrix::operator==(const Matrix& m2) | ||
{ | ||
// your implementation here | ||
} | ||
|
||
bool Matrix::operator!=(const Matrix& m2) | ||
{ | ||
// your implementation here | ||
} | ||
|
||
Matrix Matrix::operator+(const Matrix& m2) | ||
{ | ||
// your implementation here | ||
} |
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,18 @@ | ||
#pragma once | ||
|
||
class Matrix | ||
{ | ||
public: | ||
Matrix() = default; | ||
Matrix(int numRows, int numCols); | ||
|
||
void Reset(int numRows, int numCols); | ||
int& At(int row, int col); | ||
const int& At(int row, int col) const; | ||
int GetRows() const; | ||
int GetCols() const; | ||
|
||
bool operator==(const Matrix& m2); | ||
bool operator!=(const Matrix& m2); | ||
Matrix operator+(const Matrix& m2); | ||
}; |