Warning, file /sdk/codevis/thirdparty/soci/tests/odbc/test-odbc-access.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, David Courtney 0003 // Distributed under the Boost Software License, Version 1.0. 0004 // (See accompanying file LICENSE_1_0.txt or copy at 0005 // http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 0008 #include "soci/soci.h" 0009 #include "soci/odbc/soci-odbc.h" 0010 #include "common-tests.h" 0011 #include <iostream> 0012 #include <string> 0013 #include <ctime> 0014 #include <cmath> 0015 0016 using namespace soci; 0017 using namespace soci::tests; 0018 0019 std::string connectString; 0020 backend_factory const &backEnd = *soci::factory_odbc(); 0021 0022 // DDL Creation objects for common tests 0023 struct table_creator_one : public table_creator_base 0024 { 0025 table_creator_one(soci::session & sql) 0026 : table_creator_base(sql) 0027 { 0028 sql << "create table soci_test(id integer, val integer, c char, " 0029 "str varchar(20), sh integer, ul number, d float, " 0030 "num76 numeric(7,6), " 0031 "tm timestamp, i1 integer, i2 integer, i3 integer, " 0032 "name varchar(20))"; 0033 } 0034 }; 0035 0036 struct table_creator_two : public table_creator_base 0037 { 0038 table_creator_two(soci::session & sql) 0039 : table_creator_base(sql) 0040 { 0041 sql << "create table soci_test(num_float float, num_int integer," 0042 " name varchar(20), sometime datetime, chr char)"; 0043 } 0044 }; 0045 0046 struct table_creator_three : public table_creator_base 0047 { 0048 table_creator_three(soci::session & sql) 0049 : table_creator_base(sql) 0050 { 0051 sql << "create table soci_test(name varchar(100) not null, " 0052 "phone varchar(15))"; 0053 } 0054 }; 0055 0056 struct table_creator_for_get_affected_rows : table_creator_base 0057 { 0058 table_creator_for_get_affected_rows(soci::session & sql) 0059 : table_creator_base(sql) 0060 { 0061 sql << "create table soci_test(val integer)"; 0062 } 0063 }; 0064 0065 // 0066 // Support for SOCI Common Tests 0067 // 0068 0069 class test_context : public test_context_base 0070 { 0071 public: 0072 0073 test_context(backend_factory const &backend, std::string const &connstr) 0074 : test_context_base(backend, connstr) {} 0075 0076 table_creator_base * table_creator_1(soci::session& s) const 0077 { 0078 return new table_creator_one(s); 0079 } 0080 0081 table_creator_base * table_creator_2(soci::session& s) const 0082 { 0083 return new table_creator_two(s); 0084 } 0085 0086 table_creator_base * table_creator_3(soci::session& s) const 0087 { 0088 return new table_creator_three(s); 0089 } 0090 0091 table_creator_base * table_creator_4(soci::session& s) const 0092 { 0093 return new table_creator_for_get_affected_rows(s); 0094 } 0095 0096 std::string fromDual(std::string const &sql) const 0097 { 0098 return sql; 0099 } 0100 0101 std::string toDate(std::string const &datdt_string) const 0102 { 0103 return "#" + datdt_string + "#"; 0104 } 0105 0106 std::string to_date_time(std::string const &datdt_string) const 0107 { 0108 return "#" + datdt_string + "#"; 0109 } 0110 0111 virtual std::string sql_length(std::string const& s) const 0112 { 0113 return "len(" + s + ")"; 0114 } 0115 }; 0116 0117 int main(int argc, char** argv) 0118 { 0119 0120 #ifdef _MSC_VER 0121 // Redirect errors, unrecoverable problems, and assert() failures to STDERR, 0122 // instead of debug message window. 0123 // This hack is required to run assert()-driven tests by Buildbot. 0124 // NOTE: Comment this 2 lines for debugging with Visual C++ debugger to catch assertions inside. 0125 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); 0126 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); 0127 #endif //_MSC_VER 0128 0129 if (argc >= 2 && argv[1][0] != '-') 0130 { 0131 connectString = argv[1]; 0132 0133 // Replace the connect string with the process name to ensure that 0134 // CATCH uses the correct name in its messages. 0135 argv[1] = argv[0]; 0136 0137 argc--; 0138 argv++; 0139 } 0140 else 0141 { 0142 connectString = "FILEDSN=./test-access.dsn"; 0143 } 0144 0145 test_context tc(backEnd, connectString); 0146 0147 return Catch::Session().run(argc, argv); 0148 }