Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule:
- cron: '0 0 * * 1'
push:
branches: [ master ]
branches: [ '*' ]
pull_request:
branches: [ master ]

Expand All @@ -22,43 +22,53 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
compiler: [clang-6, clang-10-libc++, gcc-7, gcc-8, gcc-9]
compiler: [clang-11, clang-14, clang-18, gcc-9, gcc-12, gcc-14]
ssl: [ssl_ON, ssl_OFF]
dependencies: [dependencies_BUILT_IN]

include:
- compiler: clang-6
COMPILER_INSTALL: clang-6.0 libc++-dev
C_COMPILER: clang-6.0
CXX_COMPILER: clang++-6.0

- compiler: clang-10-libc++
COMPILER_INSTALL: clang-10 libc++-dev
C_COMPILER: clang-10
CXX_COMPILER: clang++-10

- compiler: gcc-7
COMPILER_INSTALL: gcc-7 g++-7
C_COMPILER: gcc-7
CXX_COMPILER: g++-7

- compiler: gcc-8
COMPILER_INSTALL: gcc-8 g++-8
C_COMPILER: gcc-8
CXX_COMPILER: g++-8
- compiler: clang-11
os: ubuntu-22.04
COMPILER_INSTALL: clang-11 libc++-11-dev
C_COMPILER: clang-11
CXX_COMPILER: clang++-11

- compiler: clang-14
os: ubuntu-24.04
COMPILER_INSTALL: clang-14 libc++-14-dev
C_COMPILER: clang-14
CXX_COMPILER: clang++-14

- compiler: clang-18
os: ubuntu-24.04
COMPILER_INSTALL: clang-18 libc++-18-dev
C_COMPILER: clang-18
CXX_COMPILER: clang++-18

- compiler: gcc-9
os: ubuntu-22.04
COMPILER_INSTALL: gcc-9 g++-9
C_COMPILER: gcc-9
CXX_COMPILER: g++-9

- compiler: gcc-12
os: ubuntu-24.04
COMPILER_INSTALL: gcc-12 g++-12
C_COMPILER: gcc-12
CXX_COMPILER: g++-12

- compiler: gcc-14
os: ubuntu-24.04
COMPILER_INSTALL: gcc-14 g++-14
C_COMPILER: gcc-14
CXX_COMPILER: g++-14

- ssl: ssl_ON
SSL_CMAKE_OPTION: -D WITH_OPENSSL=ON

- dependencies: dependencies_SYSTEM
compiler: compiler_SYSTEM
os: ubuntu-22.04
os: ubuntu-24.04
COMPILER_INSTALL: gcc g++
C_COMPILER: gcc
CXX_COMPILER: g++
Expand All @@ -77,9 +87,8 @@ jobs:

- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get update
sudo apt-get install -y \
docker \
cmake \
${{matrix.COMPILER_INSTALL}} \
${{matrix.DEPENDENCIES_INSTALL}}
Expand All @@ -92,6 +101,7 @@ jobs:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update -q
sudo apt install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world

- name: Configure project
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule:
- cron: '0 0 * * 1'
push:
branches: [ master ]
branches: [ '*' ]
pull_request:
branches: [ master ]
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule:
- cron: '0 0 * * 1'
push:
branches: [ master ]
branches: [ '*' ]
pull_request:
branches: [ master ]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule:
- cron: '0 0 * * 1'
push:
branches: [ master ]
branches: [ '*' ]
pull_request:
branches: [ master ]

Expand Down
29 changes: 19 additions & 10 deletions ut/utils_comparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ ::testing::AssertionResult CompareCotainersRecursive(const LeftContainer& left,
template <typename Container>
struct PrintContainer;


template <typename Left, typename Right>
::testing::AssertionResult CompareRecursive(const Left & left, const Right & right) {
if constexpr (!is_string_v<Left> && !is_string_v<Right>
&& (is_container_v<Left> || std::is_base_of_v<clickhouse::Column, std::decay_t<Left>>)
&& (is_container_v<Right> || std::is_base_of_v<clickhouse::Column, std::decay_t<Right>>) ) {
using L = std::decay_t<Left>;
using R = std::decay_t<Right>;

if constexpr (!is_string_v<L> && !is_string_v<R>
&& (is_container_v<L> || std::is_base_of_v<clickhouse::Column, L>)
&& (is_container_v<R> || std::is_base_of_v<clickhouse::Column, R>) ) {

const auto & l = maybeWrapColumnAsContainer(left);
const auto & r = maybeWrapColumnAsContainer(right);
Expand All @@ -155,24 +159,29 @@ ::testing::AssertionResult CompareRecursive(const Left & left, const Right & rig
else
return result << "\nExpected container: " << PrintContainer{l}
<< "\nActual container : " << PrintContainer{r};
}
else if constexpr (std::is_same_v<char const *, L> || std::is_same_v<char *, L>) {
return CompareRecursive(std::string_view(left), right);
}
else if constexpr (std::is_same_v<char const *, R> || std::is_same_v<char *, R>) {
return CompareRecursive(left, std::string_view(right));
} else {
if (left != right) {

// Handle std::optional<float>(nan)
// I'm too lazy to code comparison against std::nullopt, but this shpudn't be a problem in real life.
// RN comparing against std::nullopt, you'll receive an compilation error.
if constexpr (is_instantiation_of<std::optional, Left>::value && is_instantiation_of<std::optional, Right>::value)
// I'm too lazy to code comparison against std::nullopt, but this shouldn't be a problem in real life.
// RN comparing against std::nullopt, you'll get a compilation error.
if constexpr (is_instantiation_of<std::optional, L>::value && is_instantiation_of<std::optional, R>::value)
{
if (left.has_value() && right.has_value())
return CompareRecursive(*left, *right);
}
else if constexpr (is_instantiation_of<std::optional, Left>::value) {
else if constexpr (is_instantiation_of<std::optional, L>::value) {
if (left)
return CompareRecursive(*left, right);
} else if constexpr (is_instantiation_of<std::optional, Right>::value) {
} else if constexpr (is_instantiation_of<std::optional, R>::value) {
if (right)
return CompareRecursive(left, *right);
} else if constexpr (std::is_floating_point_v<Left> && std::is_floating_point_v<Right>) {
} else if constexpr (std::is_floating_point_v<L> && std::is_floating_point_v<R>) {
if (std::isnan(left) && std::isnan(right))
return ::testing::AssertionSuccess();
}
Expand Down
1 change: 1 addition & 0 deletions ut/utils_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct is_instantiation_of< Template, Template<Args...> > : std::true_type {};
template <typename T>
inline constexpr bool is_string_v = std::is_same_v<std::string, std::decay_t<T>> || std::is_same_v<std::string_view, std::decay_t<T>>;


// https://stackoverflow.com/a/34111095
template <typename...>
struct is_one_of {
Expand Down
77 changes: 76 additions & 1 deletion ut/utils_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,84 @@ TEST(CompareRecursive, CompareValues) {
EXPECT_TRUE(CompareRecursive(1.0, 1.0));
EXPECT_TRUE(CompareRecursive(1.0L, 1.0L));

EXPECT_TRUE(CompareRecursive('a', 'a'));
}

TEST(CompareRecursive, CompareStrings) {
// literals
EXPECT_TRUE(CompareRecursive("1.0L", "1.0L"));
EXPECT_TRUE(CompareRecursive(std::string{"1.0L"}, std::string{"1.0L"}));
EXPECT_TRUE(CompareRecursive("1.0L", std::string("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string("1.0L"), "1.0L"));
EXPECT_TRUE(CompareRecursive("1.0L", std::string_view("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string_view("1.0L"), "1.0L"));

// array
const char str[] = "1.0L";
EXPECT_TRUE(CompareRecursive("1.0L", str));
EXPECT_TRUE(CompareRecursive(str, "1.0L"));
EXPECT_TRUE(CompareRecursive(str, str));
EXPECT_TRUE(CompareRecursive(str, std::string("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string("1.0L"), str));
EXPECT_TRUE(CompareRecursive(str, std::string_view("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string_view("1.0L"), str));

// pointer
const char *str2 = "1.0L";
EXPECT_TRUE(CompareRecursive("1.0L", str2));
EXPECT_TRUE(CompareRecursive(str2, "1.0L"));
EXPECT_TRUE(CompareRecursive(str2, str2));
EXPECT_TRUE(CompareRecursive(str2, str));
EXPECT_TRUE(CompareRecursive(str, str2));
EXPECT_TRUE(CompareRecursive(str2, std::string("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string("1.0L"), str2));
EXPECT_TRUE(CompareRecursive(str2, std::string_view("1.0L")));
EXPECT_TRUE(CompareRecursive(std::string_view("1.0L"), str2));

// string & string_view
EXPECT_TRUE(CompareRecursive(std::string{"1.0L"}, std::string{"1.0L"}));
EXPECT_TRUE(CompareRecursive(std::string_view{"1.0L"}, std::string_view{"1.0L"}));
EXPECT_TRUE(CompareRecursive(std::string{"1.0L"}, std::string_view{"1.0L"}));
EXPECT_TRUE(CompareRecursive(std::string_view{"1.0L"}, std::string{"1.0L"}));
}

TEST(CompareRecursive, CompareContainerOfStrings) {
const std::vector<const char*> vector_of_cstrings = {
"abc",
"cde",
"ghi"
};

const std::vector<std::string> vector_of_strings = {
"abc",
"cde",
"ghi"
};

const std::vector<std::string_view> vector_of_string_views = {
"abc",
"cde",
"ghi"
};

{
// same values, but different pointers
const std::vector<const char*> vector_of_cstrings2 = {
vector_of_strings[0].data(),
vector_of_strings[1].data(),
vector_of_strings[2].data(),
};
EXPECT_TRUE(CompareRecursive(vector_of_cstrings, vector_of_cstrings2));
}

EXPECT_TRUE(CompareRecursive(vector_of_strings, vector_of_strings));
EXPECT_TRUE(CompareRecursive(vector_of_strings, vector_of_cstrings));
EXPECT_TRUE(CompareRecursive(vector_of_cstrings, vector_of_strings));

EXPECT_TRUE(CompareRecursive(vector_of_string_views, vector_of_string_views));
EXPECT_TRUE(CompareRecursive(vector_of_strings, vector_of_string_views));
EXPECT_TRUE(CompareRecursive(vector_of_string_views, vector_of_strings));
EXPECT_TRUE(CompareRecursive(vector_of_strings, vector_of_string_views));
EXPECT_TRUE(CompareRecursive(vector_of_string_views, vector_of_strings));
}

TEST(CompareRecursive, CompareContainers) {
Expand Down
Loading