Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Apr 27, 2024
2 parents aa03307 + 58a930d commit 88e343f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
skip-artifact: false
skip-crashpad: false
# macOS (x86)
- os: macos-12
- os: macos-13
qt-version: 6.5.0
arch: x86_64
force-lto: false
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ jobs:
echo "Running bump-cask-pr for cask '$C2_CASK_NAME' and version '$C2_TAGGED_VERSION'"
C2_TAGGED_VERSION_STRIPPED="${C2_TAGGED_VERSION:1}"
echo "Stripped version: '$C2_TAGGED_VERSION_STRIPPED'"
brew developer on
brew bump-cask-pr --version "$C2_TAGGED_VERSION_STRIPPED" "$C2_CASK_NAME"
6 changes: 3 additions & 3 deletions tests/src/Emojis.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "providers/emoji/Emojis.hpp"

#include "common/Literals.hpp"
#include "TestHelpers.hpp"

#include <gtest/gtest.h>
#include <QDebug>
Expand Down Expand Up @@ -53,7 +54,7 @@ TEST(Emojis, ShortcodeParsing)
}

EXPECT_EQ(output, test.expectedOutput)
<< "Input " << test.input.toStdString() << " failed";
<< "Input " << test.input << " failed";
}
}

Expand Down Expand Up @@ -165,8 +166,7 @@ TEST(Emojis, Parse)
// can't use EXPECT_EQ because EmotePtr can't be printed
if (output != test.expectedOutput)
{
EXPECT_TRUE(false)
<< "Input " << test.input.toStdString() << " failed";
EXPECT_TRUE(false) << "Input " << test.input << " failed";
}
}
}
14 changes: 8 additions & 6 deletions tests/src/LinkParser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "common/LinkParser.hpp"

#include "TestHelpers.hpp"

#include <gtest/gtest.h>
#include <QString>
#include <QStringList>
Expand All @@ -15,13 +17,13 @@ struct Case {
{
auto input = this->protocol + this->host + this->rest;
LinkParser p(input);
ASSERT_TRUE(p.result().has_value()) << input.toStdString();
ASSERT_TRUE(p.result().has_value()) << input;

const auto &r = *p.result();
ASSERT_EQ(r.source, input);
ASSERT_EQ(r.protocol, this->protocol) << this->protocol.toStdString();
ASSERT_EQ(r.host, this->host) << this->host.toStdString();
ASSERT_EQ(r.rest, this->rest) << this->rest.toStdString();
ASSERT_EQ(r.protocol, this->protocol) << this->protocol;
ASSERT_EQ(r.host, this->host) << this->host;
ASSERT_EQ(r.rest, this->rest) << this->rest;
}
};

Expand Down Expand Up @@ -126,7 +128,7 @@ TEST(LinkParser, doesntParseInvalidIpv4Links)
for (const auto &input : inputs)
{
LinkParser p(input);
ASSERT_FALSE(p.result().has_value()) << input.toStdString();
ASSERT_FALSE(p.result().has_value()) << input;
}
}

Expand Down Expand Up @@ -170,6 +172,6 @@ TEST(LinkParser, doesntParseInvalidLinks)
for (const auto &input : inputs)
{
LinkParser p(input);
ASSERT_FALSE(p.result().has_value()) << input.toStdString();
ASSERT_FALSE(p.result().has_value()) << input;
}
}
22 changes: 22 additions & 0 deletions tests/src/TestHelpers.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once

#include <QString>
#include <QStringView>

#include <mutex>
#include <ostream>

template <typename T>
class ReceivedMessage
Expand Down Expand Up @@ -42,3 +46,21 @@ class ReceivedMessage
return &this->t;
}
};

inline std::ostream &operator<<(std::ostream &os, const QStringView &str)
{
os << qUtf8Printable(str.toString());
return os;
}

inline std::ostream &operator<<(std::ostream &os, const QByteArray &bytes)
{
os << bytes.toStdString();
return os;
}

inline std::ostream &operator<<(std::ostream &os, const QString &str)
{
os << qUtf8Printable(str);
return os;
}
20 changes: 10 additions & 10 deletions tests/src/TwitchMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "providers/seventv/SeventvPersonalEmotes.hpp"
#include "providers/twitch/TwitchBadge.hpp"
#include "singletons/Emotes.hpp"
#include "TestHelpers.hpp"

#include <gtest/gtest.h>
#include <IrcConnection>
Expand Down Expand Up @@ -154,7 +155,7 @@ TEST(TwitchMessageBuilder, CommaSeparatedListTagParsing)
auto output = TwitchMessageBuilder::slashKeyValue(test.input);

EXPECT_EQ(output, test.expectedOutput)
<< "Input " << test.input.toStdString() << " failed";
<< "Input " << test.input << " failed";
}
}

Expand Down Expand Up @@ -237,12 +238,12 @@ TEST(TwitchMessageBuilder, BadgeInfoParsing)
auto outputBadgeInfo =
TwitchMessageBuilder::parseBadgeInfoTag(privmsg->tags());
EXPECT_EQ(outputBadgeInfo, test.expectedBadgeInfo)
<< "Input for badgeInfo " << test.input.toStdString() << " failed";
<< "Input for badgeInfo " << test.input << " failed";

auto outputBadges =
SharedMessageBuilder::parseBadgeTag(privmsg->tags());
EXPECT_EQ(outputBadges, test.expectedBadges)
<< "Input for badges " << test.input.toStdString() << " failed";
<< "Input for badges " << test.input << " failed";

delete privmsg;
}
Expand Down Expand Up @@ -420,8 +421,7 @@ TEST_F(TestTwitchMessageBuilder, ParseTwitchEmotes)
privmsg->tags(), originalMessage, 0);

EXPECT_EQ(actualTwitchEmotes, test.expectedTwitchEmotes)
<< "Input for twitch emotes " << test.input.toStdString()
<< " failed";
<< "Input for twitch emotes " << test.input << " failed";

delete privmsg;
}
Expand Down Expand Up @@ -624,11 +624,11 @@ TEST_F(TestTwitchMessageBuilder, IgnoresReplace)
emotes);

EXPECT_EQ(message, test.expectedMessage)
<< "Message not equal for input '" << test.input.toStdString()
<< "' - expected: '" << test.expectedMessage.toStdString()
<< "' got: '" << message.toStdString() << "'";
<< "Message not equal for input '" << test.input
<< "' - expected: '" << test.expectedMessage << "' got: '"
<< message << "'";
EXPECT_EQ(emotes, test.expectedTwitchEmotes)
<< "Twitch emotes not equal for input '" << test.input.toStdString()
<< "' and output '" << message.toStdString() << "'";
<< "Twitch emotes not equal for input '" << test.input
<< "' and output '" << message << "'";
}
}
7 changes: 4 additions & 3 deletions tests/src/XDGHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "util/XDGHelper.hpp"

#include "TestHelpers.hpp"

#include <gtest/gtest.h>
#include <QDebug>

Expand Down Expand Up @@ -57,9 +59,8 @@ TEST(XDGHelper, ParseDesktopExecProgram)
auto output = parseDesktopExecProgram(test.input);

EXPECT_EQ(output, test.expectedOutput)
<< "Input '" << test.input.toStdString() << "' failed. Expected '"
<< test.expectedOutput.toStdString() << "' but got '"
<< output.toStdString() << "'";
<< "Input '" << test.input << "' failed. Expected '"
<< test.expectedOutput << "' but got '" << output << "'";
}
}

Expand Down

0 comments on commit 88e343f

Please sign in to comment.