Skip to content

Commit

Permalink
move to gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Apr 4, 2024
1 parent 6d33bb2 commit 67414c9
Show file tree
Hide file tree
Showing 21 changed files with 718 additions and 719 deletions.
8 changes: 4 additions & 4 deletions .pkg
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Catch2]
[email protected]:motis-project/Catch2.git
[googletest]
[email protected]:motis-project/googletest.git
branch=master
commit=47d56f28a9801911c048d011b375e5631dbb658f
commit=34a46558609e05865c197f0260ab36daa7cbbb6e
[fmt]
[email protected]:motis-project/fmt.git
branch=master
commit=edb385ac526c24bc917ec4a41bb0edb28f0ca59e
[cista]
[email protected]:felixguendling/cista.git
branch=master
commit=23875effbc4f3441304137515991dbcfbc52caed
commit=251a73b51768bea0a23c538e3aa7f47648411a87

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (MSVC)
list(REMOVE_ITEM utl-test-files ${zip-test})
endif()
add_executable(utl-test ${utl-test-files})
target_link_libraries(utl-test utl Catch2::Catch2WithMain)
target_link_libraries(utl-test utl gtest gmock gtest_main)
if (NOT MSVC)
target_compile_options(utl-test PRIVATE -Wall -Wextra -Werror)
endif()
18 changes: 9 additions & 9 deletions include/utl/pipes/avg.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

namespace utl {

struct avg {
struct avg_t {
template <typename T>
friend double operator|(T&& t, avg&& f) {
auto r = make_range(std::forward<T>(t));
friend double operator|(T&& r, avg_t) {
auto sum = std::size_t{0};
auto count = std::size_t{0};
auto it = r.begin();
while (r.valid(it)) {
f.sum_ += r.read(it);
++f.count_;
sum += r.read(it);
++count;
r.next(it);
}
return f.sum_ / static_cast<double>(f.count_);
return sum / static_cast<double>(count);
}

int sum_ = 0;
int count_ = 0;
};

inline avg_t avg() { return {}; }

} // namespace utl
16 changes: 8 additions & 8 deletions test/cmd_line_parser_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "catch2/catch_all.hpp"
#include "gtest/gtest.h"

#include "utl/cmd_line_parser.h"

Expand All @@ -20,17 +20,17 @@ constexpr auto const expected_description =
--file * target file
--num_threads thread pool size)";

TEST_CASE("cmd_line_flag_test") {
TEST(cmd, cmd_line_flag_test) {
char const* args[] = {"./exe", "-c", "--file", "test", "--num_threads", "8"};
auto c = parse<config>(sizeof(args) / sizeof(char const*), args);

CHECK(c.capture_.val());
CHECK(c.file_.val() == "test");
CHECK(c.num_threads_.val() == 8);
CHECK(description<config>() == expected_description);
EXPECT_TRUE(c.capture_.val());
EXPECT_TRUE(c.file_.val() == "test");
EXPECT_TRUE(c.num_threads_.val() == 8);
EXPECT_TRUE(description<config>() == expected_description);
}

TEST_CASE("cmd_line_flag_required_test") {
TEST(cmd, cmd_line_flag_required_test) {
char const* args[] = {"./exe", "-c", "--num_threads", "8"};

bool thrown = false;
Expand All @@ -39,5 +39,5 @@ TEST_CASE("cmd_line_flag_required_test") {
} catch (...) {
thrown = true;
}
CHECK(thrown);
EXPECT_TRUE(thrown);
}
8 changes: 4 additions & 4 deletions test/is_uniform_test.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "catch2/catch_all.hpp"
#include "gtest/gtest.h"

#include "utl/is_uniform.h"

TEST_CASE("is_uniform") {
TEST(is_uniform, is_uniform) {
using utl::is_uniform;
std::vector<int> v1{1, 1, 3};
std::vector<int> v2{1, 1, 1};
CHECK(!is_uniform(v1));
CHECK(is_uniform(v2));
EXPECT_TRUE(!is_uniform(v1));
EXPECT_TRUE(is_uniform(v2));
}
Loading

0 comments on commit 67414c9

Please sign in to comment.