Messy commit. Testing suff and some improvements to how data is shown.

This commit is contained in:
eelke 2017-12-09 10:45:13 +01:00
parent bebb3391c3
commit 3a13b7ffb4
59 changed files with 2045 additions and 716 deletions

View file

@ -0,0 +1,66 @@
#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>
#include "Pgsql_Value.h"
#include "PrintTo_Qt.h"
using namespace testing;
using namespace Pgsql;
TEST(Pgsql_Value, test_int4)
{
Pgsql::Value v("1", INT4OID);
int i = (int)v;
ASSERT_EQ(i, 1);
}
TEST(Pgsql_Value, test_QDateTime)
{
Pgsql::Value v("2017-10-22 12:34:56", TIMESTAMPTZOID);
QDateTime dt = (QDateTime)v;
ASSERT_EQ(dt, QDateTime(QDate(2017, 10, 22), QTime(12, 34, 56)));
}
TEST(Pgsql_Value, test_QDateTime_2)
{
Pgsql::Value v("2017-12-01 09:38:17.339817+02", TIMESTAMPTZOID);
QDateTime dt = (QDateTime)v;
QDateTime exp(QDate(2017, 12, 1), QTime(9, 38, 17, 340),
Qt::OffsetFromUTC, 2*3600);
ASSERT_EQ(dt, exp);
}
TEST(Pgsql_Value, test_QDate)
{
Pgsql::Value v("2017-10-22", DATEOID);
QDate d = v;
ASSERT_EQ(d, QDate(2017, 10, 22));
}
TEST(Pgsql_Value, test_QTime)
{
Pgsql::Value v("12:34:56", TIMEOID);
QTime t = v;
ASSERT_EQ(t, QTime(12, 34, 56));
}
TEST(Pgsql_Value, test_QTimeMS)
{
Pgsql::Value v("09:38:17.339817+02", TIMETZOID);
QTime t = v;
ASSERT_EQ(t, QTime(9, 38, 17, 340));
}
TEST(Pgsql_Value, isString_int4)
{
Pgsql::Value v("1", INT4OID);
ASSERT_EQ(v.isString(), false);
}
TEST(Pgsql_Value, isString_varchar)
{
Pgsql::Value v("1", VARCHAROID);
ASSERT_EQ(v.isString(), true);
}