https://github.com/m7moudgadallah/cpp_testing_for_cp
Simple class used to test functionality by passing the result of function and the expected output
https://github.com/m7moudgadallah/cpp_testing_for_cp
competitive-programming unit-testing
Last synced: 8 months ago
JSON representation
Simple class used to test functionality by passing the result of function and the expected output
- Host: GitHub
- URL: https://github.com/m7moudgadallah/cpp_testing_for_cp
- Owner: m7moudGadallah
- Created: 2023-02-20T10:34:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T11:18:57.000Z (over 2 years ago)
- Last Synced: 2025-01-01T02:41:46.531Z (10 months ago)
- Topics: competitive-programming, unit-testing
- Language: C++
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testing
## Content
- ***[How to include it?](#how-to-include-it)***
- ***[How to use it?](#how-to-use-it)***## How to include it?
First download this [file](./UTest.h) and include it in your working directory like that:
```cpp
#include "UTest.h"
```## How to use it?
in `main` function create object fromt `UTest` class then call function `test` funciton take `vector of pair` as `input`
`pair` here `out`: output of your function and `exp`: is expected output of your function### Example
if we have a function called `sum` and this is it's implemenation
```c++
int sum(int x, int y) {
return x+y;
}
```now we want to test this function and we already have test cases
```
input: 1 2
expected: 3input: 3 4
expected: 7
``````c++
int main() {
UTest testObj;
vector> testStream {
make_pair(sum(1, 2), 3),
make_pair(sum(3, 4), 7)
};
testObj.test(testStream);
}
``````cpp
#include
#include "UTest.h"
using namespace std;
int sum(int x, int y) {
return x + y;
}
int main() {
UTest testObj;
vector> testStream {
make_pair(sum(1, 2), 3),
make_pair(sum(3, 4), 7)
};
testObj.test(testStream);
}
```#### output
