From 77012915e5755f82982ceb18035bb8e56878848d Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 20 Oct 2011 20:49:42 +0200 Subject: Add 64 bit integer tests to Oracle types test --- oracle/types/driver.cxx | 51 ++++++++++++++++++++++++++++++++++++++++--------- oracle/types/test.hxx | 49 +++++++++++++++++++++++++---------------------- 2 files changed, 68 insertions(+), 32 deletions(-) (limited to 'oracle') 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 bi1 (db->load (1)); + auto_ptr bil1 (db->load (1)); + auto_ptr bil2 (db->load (2)); + auto_ptr bil3 (db->load (3)); + auto_ptr bil4 (db->load (4)); + auto_ptr bil5 (db->load (5)); + auto_ptr buil1 (db->load (1)); + auto_ptr buil2 (db->load (2)); + auto_ptr buil3 (db->load (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; } }; -- cgit v1.1