mirror-chatterino2/tests/src/Updates.cpp

43 lines
1.5 KiB
C++
Raw Normal View History

#include "singletons/Updates.hpp"
#include "common/Version.hpp"
#include <gtest/gtest.h>
#include <semver/semver.hpp>
using namespace chatterino;
TEST(Updates, MustBeDowngrade)
{
EXPECT_TRUE(Updates::isDowngradeOf("1.0.0", "2.4.5"))
<< "1.0.0 must be a downgrade of 2.4.5";
EXPECT_TRUE(Updates::isDowngradeOf("2.0.0", "2.4.5"))
<< "2.0.0 must be a downgrade of 2.4.5";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.0", "2.4.5"))
<< "2.4.0 must be a downgrade of 2.4.5";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.4-beta", "2.4.5"))
<< "2.4.4-beta must be a downgrade of 2.4.5";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.5-beta", "2.4.5"))
<< "2.4.5-beta must be a downgrade of 2.4.5";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.5-beta.1", "2.4.5-beta.2"))
<< "2.4.5-beta.1 must be a downgrade of 2.4.5-beta.2";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.5-beta", "2.4.5-beta.2"))
<< "2.4.5-beta must be a downgrade of 2.4.5-beta.2";
EXPECT_TRUE(Updates::isDowngradeOf("2.4.5-beta.2", "2.4.6-beta.1"))
<< "2.4.5-beta.2 must be a downgrade of 2.4.6-beta.1";
}
TEST(Updates, MustNotBeDowngrade)
{
EXPECT_FALSE(Updates::isDowngradeOf("2.4.5", "2.4.5"))
<< "2.4.5 must not be a downgrade of 2.4.5";
EXPECT_FALSE(Updates::isDowngradeOf("2.4.5", "2.4.5-beta"))
<< "2.4.5 must not be a downgrade of 2.4.5-beta";
}
TEST(Updates, ValidateCurrentVersion)
{
EXPECT_NO_THROW(auto v = semver::from_string(CHATTERINO_VERSION))
<< "Current version must be valid semver";
}