New Repository
Had my private email in a old commit of the first repository
This commit is contained in:
commit
f25d3cc8da
20 changed files with 6534 additions and 0 deletions
6
tests/test_main.cpp
Normal file
6
tests/test_main.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
54
tests/test_sorting_functions.cpp
Normal file
54
tests/test_sorting_functions.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
// tests/sorting_tests.cpp
|
||||
#include <gtest/gtest.h>
|
||||
#include <vector>
|
||||
|
||||
template<typename T>
|
||||
void swap(T& a, T& b) noexcept
|
||||
{
|
||||
T temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void bubble_sort(std::vector<T>& in)
|
||||
{
|
||||
for (size_t i = 0; i < in.size(); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < in.size() - 1; ++j)
|
||||
{
|
||||
if (in[j] > in[j + 1])
|
||||
{
|
||||
swap(in[j], in[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(BubbleSortTest, CorrectlySortsVector) {
|
||||
std::vector input = {5, 2, 8, 1, 9};
|
||||
std::vector expected = {1, 2, 5, 8, 9};
|
||||
|
||||
bubble_sort(input);
|
||||
|
||||
EXPECT_EQ(input, expected);
|
||||
}
|
||||
|
||||
TEST(BubbleSortTest, HandlesEmptyVector) {
|
||||
std::vector<int> input = {};
|
||||
std::vector<int> expected = {};
|
||||
|
||||
bubble_sort(input);
|
||||
|
||||
EXPECT_EQ(input, expected);
|
||||
}
|
||||
|
||||
TEST(BubbleSortTest, HandlesSingleElement) {
|
||||
std::vector input = {1};
|
||||
std::vector expected = {1};
|
||||
|
||||
bubble_sort(input);
|
||||
|
||||
EXPECT_EQ(input, expected);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue