pgLab/tests/pglabtests/tst_NameManglingRules.cpp

54 lines
1.6 KiB
C++

#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>
#include "PrintTo_Qt.h"
#include "codebuilder/NameManglingRules.h"
#include "Pgsql_oids.h"
using namespace testing;
class NameManglingRulesTest : public ::testing::Test, public ::testing::WithParamInterface<
std::tuple<QString, NameManglingRules::CaseConversion, bool> > {
protected:
virtual void SetUp() override
{
NameManglingRules r;
auto p = GetParam();
//ReplaceRules replaceRules;
// { {"[ -_]", QRegularExpression::OptimizeOnFirstUsageOption }, "", true }
r.replaceRules;
//QString replaceSpaceWith; ///< default is empty string which means remove spaces
r.replaceSpaceWith = std::get<0>(p);
//CollisionHandling CollisionHandling = CollisionHandling::Restrict;
//CaseConversion caseConversion = CaseConversion::AsIs; ///< overall case conversion rule
r.caseConversion = std::get<1>(p);
//CaseConversion caseFirstChar = CaseConversion::AsIs; ///< case of the first char
r.camelCase = std::get<2>(p); ///< removes underscores and make first char after underscore uppercase
rules = r;
}
NameManglingRules rules;
};
TEST_P(NameManglingRulesTest, test1)
{
ASSERT_EQ(rules.replaceSpaceWith, std::get<0>(GetParam()));
}
TEST_P(NameManglingRulesTest, test2)
{
ASSERT_EQ(rules.camelCase, std::get<2>(GetParam()));
}
INSTANTIATE_TEST_CASE_P(InstantiationName1,
NameManglingRulesTest,
::testing::Combine(
::testing::Values("", "_", "+"),
::testing::Values(NameManglingRules::CaseConversion::AsIs,
NameManglingRules::CaseConversion::Lower,
NameManglingRules::CaseConversion::Upper),
::testing::Bool()
));