aboutsummaryrefslogtreecommitdiff
path: root/oracle
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-20 20:49:42 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 13:29:10 +0200
commit77012915e5755f82982ceb18035bb8e56878848d (patch)
tree20393fb2dbb0623eb9ab64ec1cd5fce53d7e1a81 /oracle
parent33615c685523e5f282bc585efa0ff31df7dd3742 (diff)
Add 64 bit integer tests to Oracle types test
Diffstat (limited to 'oracle')
-rw-r--r--oracle/types/driver.cxx51
-rw-r--r--oracle/types/test.hxx49
2 files changed, 68 insertions, 32 deletions
diff --git a/oracle/types/driver.cxx b/oracle/types/driver.cxx
index 55918af..2eeb2e8 100644
--- a/oracle/types/driver.cxx
+++ b/oracle/types/driver.cxx
@@ -82,15 +82,20 @@ main (int argc, char* argv[])
// Test character set conversion.
//
- // const char* unicode_str = "a \xD5\x95 \xEA\xAA\xAA \xF2\xAA\xAA\xAA";
+ const char* unicode_str = "a \xD5\x95 \xEA\xAA\xAA \xF2\xAA\xAA\xAA";
+ // Testing of character set conversion to and from the client's database
+ // character set is disabled as the server database character set may
+ // not be able to represent some Unicode characters. If this were the case
+ // the test outcome be a false negative.
+ //
// o.char_ = unicode_str;
// o.varchar2_ = unicode_str;
// o.clob_ = unicode_str;
- // o.nchar_ = unicode_str;
- // o.nvarchar2_ = unicode_str;
- // o.nclob_ = unicode_str;
+ o.nchar_ = unicode_str;
+ o.nvarchar2_ = unicode_str;
+ o.nclob_ = unicode_str;
// Persist.
//
@@ -112,14 +117,28 @@ main (int argc, char* argv[])
// Test 64 bit integers.
//
- big_ints bi (true);
- bi.id = 1;
+ big_int bi1 (1, 0x8000000000000000LL);
+ big_int bi2 (2, -123456);
+ big_int bi3 (3, 0);
+ big_int bi4 (4, 123456);
+ big_int bi5 (5, 0xFFFFFFFFFFFFFFFFULL);
+
+ big_uint bui1 (1, 0);
+ big_uint bui2 (2, 123456);
+ big_uint bui3 (3, 0xFFFFFFFFFFFFFFFFULL);
// Persist.
//
{
transaction t (db->begin ());
- db->persist (bi);
+ db->persist (bi1);
+ db->persist (bi2);
+ db->persist (bi3);
+ db->persist (bi4);
+ db->persist (bi5);
+ db->persist (bui1);
+ db->persist (bui2);
+ db->persist (bui3);
t.commit ();
}
@@ -127,10 +146,24 @@ main (int argc, char* argv[])
//
{
transaction t (db->begin ());
- auto_ptr<big_ints> bi1 (db->load<big_ints> (1));
+ auto_ptr<big_int> bil1 (db->load<big_int> (1));
+ auto_ptr<big_int> bil2 (db->load<big_int> (2));
+ auto_ptr<big_int> bil3 (db->load<big_int> (3));
+ auto_ptr<big_int> bil4 (db->load<big_int> (4));
+ auto_ptr<big_int> bil5 (db->load<big_int> (5));
+ auto_ptr<big_uint> buil1 (db->load<big_uint> (1));
+ auto_ptr<big_uint> buil2 (db->load<big_uint> (2));
+ auto_ptr<big_uint> buil3 (db->load<big_uint> (3));
t.commit ();
- assert (bi == *bi1);
+ assert (bi1 == *bil1);
+ assert (bi2 == *bil2);
+ assert (bi3 == *bil3);
+ assert (bi4 == *bil4);
+ assert (bi5 == *bil5);
+ assert (bui1 == *buil1);
+ assert (bui2 == *buil2);
+ assert (bui3 == *buil3);
}
}
catch (const odb::exception& e)
diff --git a/oracle/types/test.hxx b/oracle/types/test.hxx
index d137a1d..bfb06f9 100644
--- a/oracle/types/test.hxx
+++ b/oracle/types/test.hxx
@@ -161,39 +161,42 @@ struct object
};
#pragma db object
-struct big_ints
+struct big_uint
{
- big_ints (bool init = false)
+ big_uint (unsigned int id = 0, unsigned long long v = 0)
+ : id_ (id), value (v)
{
- if (init)
- {
- signed_zero = 0;
- signed_min = 0x8000000000000000; // –9223372036854775808
- signed_max = 0x7FFFFFFFFFFFFFFFLL; // 9223372036854775807
- unsigned_zero = 0;
- unsigned_max = 0xFFFFFFFFFFFFFFFFULL;
- }
}
#pragma db id
- unsigned int id;
+ unsigned int id_;
+
+ unsigned long long value;
+
+ bool
+ operator== (const big_uint& y) const
+ {
+ return id_ == y.id_ && value == y.value;
+ }
+};
- long long signed_zero;
- long long signed_min;
- long long signed_max;
+#pragma db object
+struct big_int
+{
+ big_int (unsigned int id = 0, long long v = 0)
+ : id_ (id), value (v)
+ {
+ }
+
+ #pragma db id
+ unsigned int id_;
- unsigned long long unsigned_zero;
- unsigned long long unsigned_max;
+ long long value;
bool
- operator== (const big_ints& y) const
+ operator== (const big_int& y) const
{
- return id == y.id &&
- signed_zero == y.signed_zero &&
- signed_min == y.signed_min &&
- signed_max == y.signed_max &&
- unsigned_zero == y.unsigned_zero &&
- unsigned_max == y.unsigned_max;
+ return id_ == y.id_ && value == y.value;
}
};