fix unit test

Signed-off-by: mrieggeramzn <mriegger@amazon.com>
This commit is contained in:
mrieggeramzn
2022-01-05 14:50:03 -08:00
parent 8ed3da5b7f
commit 7d9f9f99e6
@@ -12,6 +12,7 @@
#include <AzCore/std/typetraits/is_signed.h>
#include "IntegerPrimtitiveTestConfig.h"
#include <QApplication>
#include <QLocale.h>
#include <sstream>
namespace UnitTest
@@ -83,18 +84,6 @@ namespace UnitTest
widget->setMaximum(widget->maximum() - 1);
}
static std::string GetToolTipStringAtLimits()
{
if constexpr (std::is_signed<ValueType>::value)
{
return "[-INF, INF]";
}
else
{
return "[0, INF]";
}
}
void PropertyCtrlHandlersCreated()
{
using ::testing::Ne;
@@ -125,15 +114,19 @@ namespace UnitTest
auto& widget = m_widget;
auto& handler = m_handler;
QString tooltip;
std::string expected;
std::stringstream expected;
// Retrieve the tooltip string for this widget
auto success = handler->ModifyTooltip(widget, tooltip);
expected = GetToolTipStringAtLimits();
const QString minString = QLocale().toString(widget->minimum());
const QString maxString = QLocale().toString(widget->maximum());
expected << "[" << minString.toStdString() << ", " << maxString.toStdString() << "]";
// Expect the operation to be successful and a valid limit tooltip string generated
EXPECT_TRUE(success);
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.c_str());
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.str().c_str());
}
void HandlerMinMaxLessLimit_ModifyHandler_ExpectSuccessAndValidLessLimitToolTipString()
@@ -149,7 +142,11 @@ namespace UnitTest
// Retrieve the tooltip string for this widget
auto success = handler->ModifyTooltip(widget, tooltip);
expected << "[" << widget->minimum() << ", " << widget->maximum() << "]";
const QString minString = QLocale().toString(widget->minimum());
const QString maxString = QLocale().toString(widget->maximum());
expected << "[" << minString.toStdString() << ", " << maxString.toStdString() << "]";
// Expect the operation to be successful and a valid less than limit tooltip string generated
EXPECT_TRUE(success);