http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am new file mode 100644 index 0000000..45a824b --- /dev/null +++ b/modules/platforms/cpp/odbc-test/Makefile.am @@ -0,0 +1,81 @@ +## +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +ACLOCAL_AMFLAGS =-I m4 + +noinst_PROGRAMS = ignite-odbc-tests + +SUBDIRS = \ + include + +AM_CPPFLAGS = \ + -I$(srcdir)/include \ + -I@top_srcdir@/common/include \ + -I@top_srcdir@/common/os/linux/include \ + -I@top_srcdir@/binary/include \ + -I@top_srcdir@/odbc/include \ + -I@top_srcdir@/jni/include \ + -I@top_srcdir@/jni/os/linux/include \ + -I@top_srcdir@/core/include \ + -I@top_srcdir@/core/os/linux/include \ + -I$(JAVA_HOME)/include \ + -I$(JAVA_HOME)/include/linux \ + -DIGNITE_IMPL + +AM_CXXFLAGS = \ + -Wall \ + -std=c++0x + +ignite_odbc_tests_LDADD = \ + @top_srcdir@/core/libignite.la \ + -ldl \ + -lodbc \ + -lpthread + +ignite_odbc_tests_LDFLAGS = \ + -static-libtool-libs + +ignite_odbc_tests_SOURCES = \ + src/teamcity/teamcity_boost.cpp \ + src/teamcity/teamcity_messages.cpp \ + src/parser_test.cpp \ + src/cursor_test.cpp \ + src/connection_info_test.cpp \ + src/application_data_buffer_test.cpp \ + src/column_test.cpp \ + src/configuration_test.cpp \ + src/row_test.cpp \ + src/utility_test.cpp \ + src/queries_test.cpp \ + ../odbc/src/cursor.cpp \ + ../odbc/src/config/connection_info.cpp \ + ../odbc/src/app/application_data_buffer.cpp \ + ../odbc/src/config/configuration.cpp \ + ../odbc/src/row.cpp \ + ../odbc/src/column.cpp \ + ../odbc/src/decimal.cpp \ + ../odbc/src/utility.cpp \ + ../odbc/src/result_page.cpp + +run-check: check + ./ignite-odbc-tests -p + +clean-local: clean-check + $(RM) *.gcno *.gcda + +clean-docs: + $(RM) $(ignite_odbc_tests_OBJECTS)
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/README.TXT ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/README.TXT b/modules/platforms/cpp/odbc-test/README.TXT new file mode 100644 index 0000000..97f4c64 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/README.TXT @@ -0,0 +1 @@ +Contains IDE projects artifacts. http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/config/queries-test.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml new file mode 100644 index 0000000..f08f86d --- /dev/null +++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <!-- Set to true to enable distributed class loading for examples, default is false. --> + <property name="peerClassLoadingEnabled" value="true"/> + + <!-- Enabling ODBC. --> + <property name="odbcConfiguration"> + <bean class="org.apache.ignite.configuration.OdbcConfiguration"></bean> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="cache"/> + <property name="cacheMode" value="PARTITIONED"/> + <property name="atomicityMode" value="ATOMIC"/> + <property name="writeSynchronizationMode" value="PRIMARY_SYNC"/> + + <!-- Configure type metadata to enable queries. --> + <property name="typeMetadata"> + <list> + <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <property name="keyType" value="java.lang.Long"/> + <property name="valueType" value="TestType"/> + <property name="queryFields"> + <map> + <entry key="i8Field" value="java.lang.Byte"/> + <entry key="i16Field" value="java.lang.Short"/> + <entry key="i32Field" value="java.lang.Integer"/> + <entry key="i64Field" value="java.lang.Long"/> + <entry key="strField" value="java.lang.String"/> + <entry key="floatField" value="java.lang.Float"/> + <entry key="doubleField" value="java.lang.Double"/> + <entry key="boolField" value="java.lang.Boolean"/> + <entry key="guidField" value="java.util.UUID"/> + <entry key="dateField" value="java.util.Date"/> + <entry key="timestampField" value="java.sql.Timestamp"/> + </map> + </property> + </bean> + </list> + </property> + </bean> + </list> + </property> + + <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <!-- + Ignite provides several options for automatic discovery that can be used + instead os static IP based discovery. + --> + <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. --> + <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">--> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> + <property name="addresses"> + <list> + <!-- In distributed environment, replace with actual host IP address. --> + <value>127.0.0.1:47500..47501</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/include/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/Makefile.am b/modules/platforms/cpp/odbc-test/include/Makefile.am new file mode 100644 index 0000000..6b2d8b6 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/include/Makefile.am @@ -0,0 +1,23 @@ +## +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +ACLOCAL_AMFLAGS =-I m4 + +noinst_HEADERS = \ + teamcity/teamcity_messages.h \ + test_type.h + http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h b/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h new file mode 100644 index 0000000..81a915b --- /dev/null +++ b/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h @@ -0,0 +1,55 @@ +/* Copyright 2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Revision: 88625 $ +*/ + +#ifndef H_TEAMCITY_MESSAGES +#define H_TEAMCITY_MESSAGES + +#include <string> +#include <iostream> + +namespace JetBrains { + +std::string getFlowIdFromEnvironment(); +bool underTeamcity(); + +class TeamcityMessages { + std::ostream *m_out; + +protected: + std::string escape(std::string s); + + void openMsg(const std::string &name); + void writeProperty(std::string name, std::string value); + void closeMsg(); + +public: + TeamcityMessages(); + + void setOutput(std::ostream &); + + void suiteStarted(std::string name, std::string flowid = ""); + void suiteFinished(std::string name, std::string flowid = ""); + + void testStarted(std::string name, std::string flowid = ""); + void testFailed(std::string name, std::string message, std::string details, std::string flowid = ""); + void testIgnored(std::string name, std::string message, std::string flowid = ""); + void testFinished(std::string name, int durationMs = -1, std::string flowid = ""); +}; + +} + +#endif /* H_TEAMCITY_MESSAGES */ http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/include/test_type.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/test_type.h b/modules/platforms/cpp/odbc-test/include/test_type.h new file mode 100644 index 0000000..2a4a979 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/include/test_type.h @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _IGNITE_ODBC_TEST_TEST_TYPE +#define _IGNITE_ODBC_TEST_TEST_TYPE + +#include <string> + +#include "ignite/ignite.h" +#include "ignite/ignition.h" + +namespace ignite +{ + struct TestType + { + TestType() : + i8Field(0), + i16Field(0), + i32Field(0), + i64Field(0), + floatField(0.0f), + doubleField(0.0), + boolField(false), + dateField(), + timestampField() + { + // No-op. + } + + TestType(int8_t i8Field, int16_t i16Field, int32_t i32Field, + int64_t i64Field, const std::string& strField, float floatField, + double doubleField, bool boolField, const Guid& guidField, + const Date& dateField, const Timestamp& timestampField) : + i8Field(i8Field), + i16Field(i16Field), + i32Field(i32Field), + i64Field(i64Field), + strField(strField), + floatField(floatField), + doubleField(doubleField), + boolField(boolField), + guidField(guidField), + dateField(dateField), + timestampField(timestampField) + { + // No-op. + } + + int8_t i8Field; + int16_t i16Field; + int32_t i32Field; + int64_t i64Field; + std::string strField; + float floatField; + double doubleField; + bool boolField; + Guid guidField; + Date dateField; + Timestamp timestampField; + }; +} + +namespace ignite +{ + namespace binary + { + IGNITE_BINARY_TYPE_START(ignite::TestType) + + typedef ignite::TestType TestType; + + IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestType) + IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestType) + IGNITE_BINARY_GET_FIELD_ID_AS_HASH + IGNITE_BINARY_GET_HASH_CODE_ZERO(TestType) + IGNITE_BINARY_IS_NULL_FALSE(TestType) + IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType) + + void Write(BinaryWriter& writer, TestType obj) + { + writer.WriteInt8("i8Field", obj.i8Field); + writer.WriteInt16("i16Field", obj.i16Field); + writer.WriteInt32("i32Field", obj.i32Field); + writer.WriteInt64("i64Field", obj.i64Field); + writer.WriteString("strField", obj.strField); + writer.WriteFloat("floatField", obj.floatField); + writer.WriteDouble("doubleField", obj.doubleField); + writer.WriteBool("boolField", obj.boolField); + writer.WriteGuid("guidField", obj.guidField); + writer.WriteDate("dateField", obj.dateField); + writer.WriteTimestamp("timestampField", obj.timestampField); + } + + TestType Read(BinaryReader& reader) + { + int8_t i8Field = reader.ReadInt8("i8Field"); + int16_t i16Field = reader.ReadInt16("i16Field"); + int32_t i32Field = reader.ReadInt32("i32Field"); + int64_t i64Field = reader.ReadInt64("i64Field"); + std::string strField = reader.ReadString("strField"); + float floatField = reader.ReadFloat("floatField"); + double doubleField = reader.ReadDouble("doubleField"); + bool boolField = reader.ReadBool("boolField"); + Guid guidField = reader.ReadGuid("guidField"); + Date dateField = reader.ReadDate("dateField"); + Timestamp timestampField = reader.ReadTimestamp("timestampField"); + + return TestType(i8Field, i16Field, i32Field, i64Field, strField, + floatField, doubleField, boolField, guidField, dateField, + timestampField); + } + + IGNITE_BINARY_TYPE_END + } +}; + +#endif // _IGNITE_ODBC_TEST_TEST_TYPE http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj new file mode 100644 index 0000000..d634cb3 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{309BEA40-495D-463F-98D5-4657F03F6D8F}</ProjectGuid> + <RootNamespace>odbctest</RootNamespace> + <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v100</PlatformToolset> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v100</PlatformToolset> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v100</PlatformToolset> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v100</PlatformToolset> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <SDLCheck>true</SDLCheck> + <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\jni\include;$(ProjectDir)\..\..\..\jni\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src;$(BOOST_HOME)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;IGNITE_TESTS_32;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ExceptionHandling>Async</ExceptionHandling> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <SDLCheck>true</SDLCheck> + <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\jni\include;$(ProjectDir)\..\..\..\jni\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src;$(BOOST_HOME)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ExceptionHandling>Async</ExceptionHandling> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\jni\include;$(ProjectDir)\..\..\..\jni\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src;$(BOOST_HOME)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;IGNITE_TESTS_32;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ExceptionHandling>Async</ExceptionHandling> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\jni\include;$(ProjectDir)\..\..\..\jni\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src;$(BOOST_HOME)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ExceptionHandling>Async</ExceptionHandling> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\odbc\src\app\application_data_buffer.cpp" /> + <ClCompile Include="..\..\..\odbc\src\column.cpp" /> + <ClCompile Include="..\..\..\odbc\src\config\configuration.cpp" /> + <ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp" /> + <ClCompile Include="..\..\..\odbc\src\cursor.cpp" /> + <ClCompile Include="..\..\..\odbc\src\decimal.cpp" /> + <ClCompile Include="..\..\..\odbc\src\result_page.cpp" /> + <ClCompile Include="..\..\..\odbc\src\row.cpp" /> + <ClCompile Include="..\..\..\odbc\src\utility.cpp" /> + <ClCompile Include="..\..\src\application_data_buffer_test.cpp" /> + <ClCompile Include="..\..\src\column_test.cpp" /> + <ClCompile Include="..\..\src\configuration_test.cpp" /> + <ClCompile Include="..\..\src\connection_info_test.cpp" /> + <ClCompile Include="..\..\src\cursor_test.cpp" /> + <ClCompile Include="..\..\src\queries_test.cpp" /> + <ClCompile Include="..\..\src\parser_test.cpp" /> + <ClCompile Include="..\..\src\row_test.cpp" /> + <ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" /> + <ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" /> + <ClCompile Include="..\..\src\utility_test.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\include\teamcity\teamcity_messages.h" /> + <ClInclude Include="..\..\include\test_type.h" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj"> + <Project>{4f15669b-92eb-49f0-b774-8f19bae0b960}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj"> + <Project>{b63f2e01-5157-4719-8491-0e1c7cd3b701}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\core\project\vs\core.vcxproj"> + <Project>{e2dea693-f2ea-43c2-a813-053378f6e4db}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\jni\project\vs\jni.vcxproj"> + <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="..\..\config\queries-test.xml" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters new file mode 100644 index 0000000..f47d990 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Code"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Externals"> + <UniqueIdentifier>{cc75fc86-c08d-428a-8ae3-f9979e4588ab}</UniqueIdentifier> + </Filter> + <Filter Include="Code\CacheTypes"> + <UniqueIdentifier>{43a56b9a-0f5c-4c22-8836-1102252497a4}</UniqueIdentifier> + </Filter> + <Filter Include="Code\TeamCity"> + <UniqueIdentifier>{5438a56d-1009-412a-86e3-ceb1112af275}</UniqueIdentifier> + </Filter> + <Filter Include="Configs"> + <UniqueIdentifier>{fe8a65d3-4f84-4051-ac62-cf4e0f788b43}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\src\configuration_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\connection_info_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\parser_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\application_data_buffer_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\row_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\cursor_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\utility_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\src\column_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\app\application_data_buffer.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\column.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\config\configuration.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\cursor.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\decimal.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\result_page.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\row.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\..\odbc\src\utility.cpp"> + <Filter>Externals</Filter> + </ClCompile> + <ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp"> + <Filter>Code\TeamCity</Filter> + </ClCompile> + <ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp"> + <Filter>Code\TeamCity</Filter> + </ClCompile> + <ClCompile Include="..\..\src\queries_test.cpp"> + <Filter>Code</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\include\test_type.h"> + <Filter>Code\CacheTypes</Filter> + </ClInclude> + <ClInclude Include="..\..\include\teamcity\teamcity_messages.h"> + <Filter>Code\TeamCity</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <None Include="..\..\config\queries-test.xml"> + <Filter>Configs</Filter> + </None> + </ItemGroup> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp new file mode 100644 index 0000000..d2ed033 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp @@ -0,0 +1,1001 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MSC_VER +# define BOOST_TEST_DYN_LINK +#endif + +#include <ignite/odbc/system/odbc_constants.h> + +#include <boost/test/unit_test.hpp> + +#include <ignite/guid.h> +#include <ignite/odbc/decimal.h> +#include <ignite/odbc/app/application_data_buffer.h> +#include <ignite/odbc/utility.h> + +#define FLOAT_PRECISION 0.0000001f + +using namespace ignite; +using namespace ignite::odbc; +using namespace ignite::odbc::app; +using namespace ignite::odbc::type_traits; + +using ignite::impl::binary::BinaryUtils; + +BOOST_AUTO_TEST_SUITE(ApplicationDataBufferTestSuite) + +BOOST_AUTO_TEST_CASE(TestPutIntToString) +{ + char buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset); + + appBuf.PutInt8(12); + BOOST_CHECK(!strcmp(buffer, "12")); + BOOST_CHECK(reslen == strlen("12")); + + appBuf.PutInt8(-12); + BOOST_CHECK(!strcmp(buffer, "-12")); + BOOST_CHECK(reslen == strlen("-12")); + + appBuf.PutInt16(9876); + BOOST_CHECK(!strcmp(buffer, "9876")); + BOOST_CHECK(reslen == strlen("9876")); + + appBuf.PutInt16(-9876); + BOOST_CHECK(!strcmp(buffer, "-9876")); + BOOST_CHECK(reslen == strlen("-9876")); + + appBuf.PutInt32(1234567); + BOOST_CHECK(!strcmp(buffer, "1234567")); + BOOST_CHECK(reslen == strlen("1234567")); + + appBuf.PutInt32(-1234567); + BOOST_CHECK(!strcmp(buffer, "-1234567")); + BOOST_CHECK(reslen == strlen("-1234567")); +} + +BOOST_AUTO_TEST_CASE(TestPutFloatToString) +{ + char buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset); + + appBuf.PutFloat(12.42f); + BOOST_CHECK(!strcmp(buffer, "12.42")); + BOOST_CHECK(reslen == strlen("12.42")); + + appBuf.PutFloat(-12.42f); + BOOST_CHECK(!strcmp(buffer, "-12.42")); + BOOST_CHECK(reslen == strlen("-12.42")); + + appBuf.PutDouble(1000.21); + BOOST_CHECK(!strcmp(buffer, "1000.21")); + BOOST_CHECK(reslen == strlen("1000.21")); + + appBuf.PutDouble(-1000.21); + BOOST_CHECK(!strcmp(buffer, "-1000.21")); + BOOST_CHECK(reslen == strlen("-1000.21")); +} + +BOOST_AUTO_TEST_CASE(TestPutGuidToString) +{ + char buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset); + + ignite::Guid guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL); + + appBuf.PutGuid(guid); + + BOOST_CHECK(!strcmp(buffer, "1da1ef8f-39ff-4d62-8b72-e8e9f3371801")); + BOOST_CHECK(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801")); +} + +BOOST_AUTO_TEST_CASE(TestGetGuidFromString) +{ + char buffer[] = "1da1ef8f-39ff-4d62-8b72-e8e9f3371801"; + SqlLen reslen; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer) - 1, &reslen, 0); + + ignite::Guid guid = appBuf.GetGuid(); + + BOOST_CHECK_EQUAL(guid, Guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL)); +} + +BOOST_AUTO_TEST_CASE(TestPutBinaryToString) +{ + char buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset); + + uint8_t binary[] = { 0x21, 0x84, 0xF4, 0xDC, 0x01, 0x00, 0xFF, 0xF0 }; + + appBuf.PutBinaryData(binary, sizeof(binary)); + + BOOST_CHECK(!strcmp(buffer, "2184f4dc0100fff0")); + BOOST_CHECK(reslen == strlen("2184f4dc0100fff0")); +} + +BOOST_AUTO_TEST_CASE(TestPutStringToString) +{ + char buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset); + + std::string testString("Test string"); + + appBuf.PutString(testString); + + BOOST_CHECK(!strcmp(buffer, testString.c_str())); + BOOST_CHECK(reslen == testString.size()); +} + +BOOST_AUTO_TEST_CASE(TestPutStringToWstring) +{ + wchar_t buffer[1024]; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_WCHAR, buffer, sizeof(buffer), &reslen, &offset); + + std::string testString("Test string"); + + appBuf.PutString(testString); + BOOST_CHECK(!wcscmp(buffer, L"Test string")); +} + +BOOST_AUTO_TEST_CASE(TestPutStringToLong) +{ + long numBuf; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, &offset); + + appBuf.PutString("424242424"); + BOOST_CHECK(numBuf == 424242424L); + + appBuf.PutString("-424242424"); + BOOST_CHECK(numBuf == -424242424L); +} + +BOOST_AUTO_TEST_CASE(TestPutStringToTiny) +{ + int8_t numBuf; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_TINYINT, &numBuf, sizeof(numBuf), &reslen, &offset); + + appBuf.PutString("12"); + BOOST_CHECK(numBuf == 12); + + appBuf.PutString("-12"); + BOOST_CHECK(numBuf == -12); +} + +BOOST_AUTO_TEST_CASE(TestPutStringToFloat) +{ + float numBuf; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset); + + appBuf.PutString("12.21"); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 12.21, FLOAT_PRECISION); + + appBuf.PutString("-12.21"); + BOOST_CHECK_CLOSE_FRACTION(numBuf, -12.21, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestPutIntToFloat) +{ + float numBuf; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset); + + appBuf.PutInt8(5); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 5.0, FLOAT_PRECISION); + + appBuf.PutInt8(-5); + BOOST_CHECK_CLOSE_FRACTION(numBuf, -5.0, FLOAT_PRECISION); + + appBuf.PutInt16(4242); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 4242.0, FLOAT_PRECISION); + + appBuf.PutInt16(-4242); + BOOST_CHECK_CLOSE_FRACTION(numBuf, -4242.0, FLOAT_PRECISION); + + appBuf.PutInt32(1234567); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 1234567.0, FLOAT_PRECISION); + + appBuf.PutInt32(-1234567); + BOOST_CHECK_CLOSE_FRACTION(numBuf, -1234567.0, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestPutFloatToShort) +{ + short numBuf; + SqlLen reslen; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &numBuf, sizeof(numBuf), &reslen, &offset); + + appBuf.PutDouble(5.42); + BOOST_CHECK(numBuf == 5); + + appBuf.PutDouble(-5.42); + BOOST_CHECK(numBuf == -5.0); + + appBuf.PutFloat(42.99f); + BOOST_CHECK(numBuf == 42); + + appBuf.PutFloat(-42.99f); + BOOST_CHECK(numBuf == -42); +} + +BOOST_AUTO_TEST_CASE(TestPutDecimalToDouble) +{ + double numBuf; + SqlLen reslen; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, sizeof(numBuf), &reslen, 0); + + Decimal decimal; + + BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(decimal), 0.0, FLOAT_PRECISION); + + appBuf.PutDecimal(decimal); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 0.0, FLOAT_PRECISION); + + int8_t mag1[] = { 1, 0 }; + + decimal = Decimal(0, mag1, sizeof(mag1)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK_CLOSE_FRACTION(numBuf, 256.0, FLOAT_PRECISION); + + int8_t mag2[] = { 2, 23 }; + + decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK_CLOSE_FRACTION(numBuf, -53.5, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestPutDecimalToLong) +{ + long numBuf; + SqlLen reslen; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, 0); + + Decimal decimal; + + appBuf.PutDecimal(decimal); + BOOST_CHECK(numBuf == 0); + + int8_t mag1[] = { 1, 0 }; + + decimal = Decimal(0, mag1, sizeof(mag1)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK(numBuf == 256); + + int8_t mag2[] = { 2, 23 }; + + decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK(numBuf == -53); +} + +BOOST_AUTO_TEST_CASE(TestPutDecimalToString) +{ + char strBuf[64]; + SqlLen reslen; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0); + + Decimal decimal; + + appBuf.PutDecimal(decimal); + BOOST_CHECK(std::string(strBuf, reslen) == "0"); + + int8_t mag1[] = { 1, 0 }; + + decimal = Decimal(0, mag1, sizeof(mag1)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK(std::string(strBuf, reslen) == "256"); + + int8_t mag2[] = { 2, 23 }; + + decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK(std::string(strBuf, reslen) == "-53.5"); +} + +BOOST_AUTO_TEST_CASE(TestPutDecimalToNumeric) +{ + SQL_NUMERIC_STRUCT buf; + SqlLen reslen; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_NUMERIC, &buf, sizeof(buf), &reslen, 0); + + Decimal decimal; + + appBuf.PutDecimal(decimal); + BOOST_CHECK_EQUAL(1, buf.sign); // Positive + BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification + BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20. + + for (int i = 0; i < SQL_MAX_NUMERIC_LEN; ++i) + BOOST_CHECK_EQUAL(0, buf.val[i]); + + // Trying to store 123.45 => 12345 => 0x3039 => [0x30, 0x39]. + uint8_t mag1[] = { 0x30, 0x39 }; + + decimal = Decimal(2, reinterpret_cast<int8_t*>(mag1), sizeof(mag1)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK_EQUAL(1, buf.sign); // Positive + BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification + BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20. + + // 123.45 => (scale=0) 123 => 0x7B => [0x7B]. + BOOST_CHECK_EQUAL(buf.val[0], 0x7B); + + for (int i = 1; i < SQL_MAX_NUMERIC_LEN; ++i) + BOOST_CHECK_EQUAL(0, buf.val[i]); + + // Trying to store 12345.678 => 12345678 => 0xBC614E => [0xBC, 0x61, 0x4E]. + uint8_t mag2[] = { 0xBC, 0x61, 0x4E }; + + decimal = Decimal(3 | 0x80000000, reinterpret_cast<int8_t*>(mag2), sizeof(mag2)); + + appBuf.PutDecimal(decimal); + BOOST_CHECK_EQUAL(2, buf.sign); // Negative + BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification + BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20. + + // 12345.678 => (scale=0) 12345 => 0x3039 => [0x39, 0x30]. + BOOST_CHECK_EQUAL(buf.val[0], 0x39); + BOOST_CHECK_EQUAL(buf.val[1], 0x30); + + for (int i = 2; i < SQL_MAX_NUMERIC_LEN; ++i) + BOOST_CHECK_EQUAL(0, buf.val[i]); +} + +BOOST_AUTO_TEST_CASE(TestPutDateToString) +{ + char strBuf[64] = { 0 }; + SqlLen reslen = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0); + + Date date = BinaryUtils::MakeDateGmt(1999, 2, 22); + + appBuf.PutDate(date); + + BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("1999-02-22")); +} + +BOOST_AUTO_TEST_CASE(TestPutTimestampToString) +{ + char strBuf[64] = { 0 }; + SqlLen reslen = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0); + + Timestamp date = BinaryUtils::MakeTimestampGmt(2018, 11, 1, 17, 45, 59); + + appBuf.PutTimestamp(date); + + BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("2018-11-01 17:45:59")); +} + +BOOST_AUTO_TEST_CASE(TestPutDateToDate) +{ + SQL_DATE_STRUCT buf = { 0 }; + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr); + + Date date = BinaryUtils::MakeDateGmt(1984, 5, 27); + + appBuf.PutDate(date); + + BOOST_CHECK_EQUAL(1984, buf.year); + BOOST_CHECK_EQUAL(5, buf.month); + BOOST_CHECK_EQUAL(27, buf.day); +} + +BOOST_AUTO_TEST_CASE(TestPutTimestampToDate) +{ + SQL_DATE_STRUCT buf = { 0 }; + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr); + + Timestamp ts = BinaryUtils::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623); + + appBuf.PutTimestamp(ts); + + BOOST_CHECK_EQUAL(2004, buf.year); + BOOST_CHECK_EQUAL(8, buf.month); + BOOST_CHECK_EQUAL(14, buf.day); +} + +BOOST_AUTO_TEST_CASE(TestPutTimestampToTimestamp) +{ + SQL_TIMESTAMP_STRUCT buf = { 0 }; + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr); + + Timestamp ts = BinaryUtils::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623); + + appBuf.PutTimestamp(ts); + + BOOST_CHECK_EQUAL(2004, buf.year); + BOOST_CHECK_EQUAL(8, buf.month); + BOOST_CHECK_EQUAL(14, buf.day); + BOOST_CHECK_EQUAL(6, buf.hour); + BOOST_CHECK_EQUAL(34, buf.minute); + BOOST_CHECK_EQUAL(51, buf.second); + BOOST_CHECK_EQUAL(573948623, buf.fraction); +} + +BOOST_AUTO_TEST_CASE(TestPutDateToTimestamp) +{ + SQL_TIMESTAMP_STRUCT buf = { 0 }; + + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr); + + Date date = BinaryUtils::MakeDateGmt(1984, 5, 27); + + appBuf.PutDate(date); + + BOOST_CHECK_EQUAL(1984, buf.year); + BOOST_CHECK_EQUAL(5, buf.month); + BOOST_CHECK_EQUAL(27, buf.day); + BOOST_CHECK_EQUAL(0, buf.hour); + BOOST_CHECK_EQUAL(0, buf.minute); + BOOST_CHECK_EQUAL(0, buf.second); + BOOST_CHECK_EQUAL(0, buf.fraction); +} + +BOOST_AUTO_TEST_CASE(TestGetStringFromLong) +{ + long numBuf = 42; + SqlLen reslen = sizeof(numBuf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, reslen, &reslen, &offset); + + std::string res = appBuf.GetString(32); + + BOOST_CHECK(res == "42"); + + numBuf = -77; + + res = appBuf.GetString(32); + + BOOST_CHECK(res == "-77"); +} + +BOOST_AUTO_TEST_CASE(TestGetStringFromDouble) +{ + double numBuf = 43.36; + SqlLen reslen = sizeof(numBuf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, reslen, &reslen, &offset); + + std::string res = appBuf.GetString(32); + + BOOST_CHECK(res == "43.36"); + + numBuf = -58.91; + + res = appBuf.GetString(32); + + BOOST_CHECK(res == "-58.91"); +} + +BOOST_AUTO_TEST_CASE(TestGetStringFromString) +{ + char buf[] = "Some data 32d2d5hs"; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset); + + std::string res = appBuf.GetString(reslen); + + BOOST_CHECK(res.compare(buf)); +} + +BOOST_AUTO_TEST_CASE(TestGetFloatFromUshort) +{ + unsigned short numBuf = 7162; + SqlLen reslen = sizeof(numBuf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT, &numBuf, reslen, &reslen, &offset); + + float resFloat = appBuf.GetFloat(); + + BOOST_CHECK_CLOSE_FRACTION(resFloat, 7162.0f, FLOAT_PRECISION); + + double resDouble = appBuf.GetDouble(); + + BOOST_CHECK_CLOSE_FRACTION(resDouble, 7162.0, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestGetFloatFromString) +{ + char buf[] = "28.562"; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset); + + float resFloat = appBuf.GetFloat(); + + BOOST_CHECK_CLOSE_FRACTION(resFloat, 28.562f, FLOAT_PRECISION); + + double resDouble = appBuf.GetDouble(); + + BOOST_CHECK_CLOSE_FRACTION(resDouble, 28.562, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestGetFloatFromFloat) +{ + float buf = 207.49f; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset); + + float resFloat = appBuf.GetFloat(); + + BOOST_CHECK_CLOSE_FRACTION(resFloat, 207.49f, FLOAT_PRECISION); + + double resDouble = appBuf.GetDouble(); + + BOOST_CHECK_CLOSE_FRACTION(resDouble, 207.49, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestGetFloatFromDouble) +{ + double buf = 893.162; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset); + + float resFloat = appBuf.GetFloat(); + + BOOST_CHECK_CLOSE_FRACTION(resFloat, 893.162f, FLOAT_PRECISION); + + double resDouble = appBuf.GetDouble(); + + BOOST_CHECK_CLOSE_FRACTION(resDouble, 893.162, FLOAT_PRECISION); +} + +BOOST_AUTO_TEST_CASE(TestGetIntFromString) +{ + char buf[] = "39"; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset); + + int64_t resInt64 = appBuf.GetInt64(); + + BOOST_CHECK(resInt64 == 39); + + int32_t resInt32 = appBuf.GetInt32(); + + BOOST_CHECK(resInt32 == 39); + + int16_t resInt16 = appBuf.GetInt16(); + + BOOST_CHECK(resInt16 == 39); + + int8_t resInt8 = appBuf.GetInt8(); + + BOOST_CHECK(resInt8 == 39); +} + +BOOST_AUTO_TEST_CASE(TestGetIntFromFloat) +{ + float buf = -107.49f; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset); + + int64_t resInt64 = appBuf.GetInt64(); + + BOOST_CHECK(resInt64 == -107); + + int32_t resInt32 = appBuf.GetInt32(); + + BOOST_CHECK(resInt32 == -107); + + int16_t resInt16 = appBuf.GetInt16(); + + BOOST_CHECK(resInt16 == -107); + + int8_t resInt8 = appBuf.GetInt8(); + + BOOST_CHECK(resInt8 == -107); +} + +BOOST_AUTO_TEST_CASE(TestGetIntFromDouble) +{ + double buf = 42.97f; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset); + + int64_t resInt64 = appBuf.GetInt64(); + + BOOST_CHECK(resInt64 == 42); + + int32_t resInt32 = appBuf.GetInt32(); + + BOOST_CHECK(resInt32 == 42); + + int16_t resInt16 = appBuf.GetInt16(); + + BOOST_CHECK(resInt16 == 42); + + int8_t resInt8 = appBuf.GetInt8(); + + BOOST_CHECK(resInt8 == 42); +} + +BOOST_AUTO_TEST_CASE(TestGetIntFromBigint) +{ + uint64_t buf = 19; + SqlLen reslen = sizeof(buf); + size_t* offset = 0; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf, reslen, &reslen, &offset); + + int64_t resInt64 = appBuf.GetInt64(); + + BOOST_CHECK(resInt64 == 19); + + int32_t resInt32 = appBuf.GetInt32(); + + BOOST_CHECK(resInt32 == 19); + + int16_t resInt16 = appBuf.GetInt16(); + + BOOST_CHECK(resInt16 == 19); + + int8_t resInt8 = appBuf.GetInt8(); + + BOOST_CHECK(resInt8 == 19); +} + +BOOST_AUTO_TEST_CASE(TestGetIntWithOffset) +{ + struct TestStruct + { + uint64_t val; + SqlLen reslen; + }; + + TestStruct buf[2] = { + { 12, sizeof(uint64_t) }, + { 42, sizeof(uint64_t) } + }; + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr); + + int64_t val = appBuf.GetInt64(); + + BOOST_CHECK(val == 12); + + offset += sizeof(TestStruct); + + val = appBuf.GetInt64(); + + BOOST_CHECK(val == 42); + + offsetPtr = 0; + + val = appBuf.GetInt64(); + + BOOST_CHECK(val == 12); +} + +BOOST_AUTO_TEST_CASE(TestSetStringWithOffset) +{ + struct TestStruct + { + char val[64]; + SqlLen reslen; + }; + + TestStruct buf[2] = { + { "", 0 }, + { "", 0 } + }; + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr); + + appBuf.PutString("Hello Ignite!"); + + std::string res(buf[0].val, buf[0].reslen); + + BOOST_CHECK(buf[0].reslen == strlen("Hello Ignite!")); + BOOST_CHECK(res == "Hello Ignite!"); + BOOST_CHECK(res.size() == strlen("Hello Ignite!")); + + offset += sizeof(TestStruct); + + appBuf.PutString("Hello with offset!"); + + res.assign(buf[0].val, buf[0].reslen); + + BOOST_CHECK(res == "Hello Ignite!"); + BOOST_CHECK(res.size() == strlen("Hello Ignite!")); + BOOST_CHECK(buf[0].reslen == strlen("Hello Ignite!")); + + res.assign(buf[1].val, buf[1].reslen); + + BOOST_CHECK(res == "Hello with offset!"); + BOOST_CHECK(res.size() == strlen("Hello with offset!")); + BOOST_CHECK(buf[1].reslen == strlen("Hello with offset!")); +} + +BOOST_AUTO_TEST_CASE(TestGetDateFromString) +{ + char buf[] = "1999-02-22"; + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0], sizeof(buf), &reslen, &offsetPtr); + + Date date = appBuf.GetDate(); + + tm tmDate; + + bool success = BinaryUtils::DateToCTm(date, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(1999, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(2, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(22, tmDate.tm_mday); + BOOST_CHECK_EQUAL(0, tmDate.tm_hour); + BOOST_CHECK_EQUAL(0, tmDate.tm_min); + BOOST_CHECK_EQUAL(0, tmDate.tm_sec); +} + +BOOST_AUTO_TEST_CASE(TestGetTimestampFromString) +{ + LOG_MSG("Test\n"); + LOG_MSG("Test\n"); + LOG_MSG("Test\n"); + LOG_MSG("Test\n"); + + char buf[] = "2018-11-01 17:45:59"; + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0], sizeof(buf), &reslen, &offsetPtr); + + Timestamp date = appBuf.GetTimestamp(); + + tm tmDate; + + bool success = BinaryUtils::TimestampToCTm(date, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(2018, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(11, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(1, tmDate.tm_mday); + BOOST_CHECK_EQUAL(17, tmDate.tm_hour); + BOOST_CHECK_EQUAL(45, tmDate.tm_min); + BOOST_CHECK_EQUAL(59, tmDate.tm_sec); +} + +BOOST_AUTO_TEST_CASE(TestGetDateFromDate) +{ + SQL_DATE_STRUCT buf = { 0 }; + + buf.year = 1984; + buf.month = 5; + buf.day = 27; + + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr); + + Date date = appBuf.GetDate(); + + tm tmDate; + + bool success = BinaryUtils::DateToCTm(date, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(1984, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(5, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(27, tmDate.tm_mday); + BOOST_CHECK_EQUAL(0, tmDate.tm_hour); + BOOST_CHECK_EQUAL(0, tmDate.tm_min); + BOOST_CHECK_EQUAL(0, tmDate.tm_sec); +} + +BOOST_AUTO_TEST_CASE(TestGetTimestampFromDate) +{ + SQL_DATE_STRUCT buf = { 0 }; + + buf.year = 1984; + buf.month = 5; + buf.day = 27; + + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr); + + Timestamp ts = appBuf.GetTimestamp(); + + tm tmDate; + + bool success = BinaryUtils::TimestampToCTm(ts, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(1984, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(5, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(27, tmDate.tm_mday); + BOOST_CHECK_EQUAL(0, tmDate.tm_hour); + BOOST_CHECK_EQUAL(0, tmDate.tm_min); + BOOST_CHECK_EQUAL(0, tmDate.tm_sec); +} + +BOOST_AUTO_TEST_CASE(TestGetTimestampFromTimestamp) +{ + SQL_TIMESTAMP_STRUCT buf = { 0 }; + + buf.year = 2004; + buf.month = 8; + buf.day = 14; + buf.hour = 6; + buf.minute = 34; + buf.second = 51; + buf.fraction = 573948623; + + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr); + + Timestamp ts = appBuf.GetTimestamp(); + + tm tmDate; + + bool success = BinaryUtils::TimestampToCTm(ts, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(2004, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(8, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(14, tmDate.tm_mday); + BOOST_CHECK_EQUAL(6, tmDate.tm_hour); + BOOST_CHECK_EQUAL(34, tmDate.tm_min); + BOOST_CHECK_EQUAL(51, tmDate.tm_sec); + BOOST_CHECK_EQUAL(573948623, ts.GetSecondFraction()); +} + +BOOST_AUTO_TEST_CASE(TestGetDateFromTimestamp) +{ + SQL_TIMESTAMP_STRUCT buf = { 0 }; + + buf.year = 2004; + buf.month = 8; + buf.day = 14; + buf.hour = 6; + buf.minute = 34; + buf.second = 51; + buf.fraction = 573948623; + + SqlLen reslen = sizeof(buf); + + size_t offset = 0; + size_t* offsetPtr = &offset; + + ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr); + + Date date = appBuf.GetDate(); + + tm tmDate; + + bool success = BinaryUtils::DateToCTm(date, tmDate); + + BOOST_REQUIRE(success); + + BOOST_CHECK_EQUAL(2004, tmDate.tm_year + 1900); + BOOST_CHECK_EQUAL(8, tmDate.tm_mon + 1); + BOOST_CHECK_EQUAL(14, tmDate.tm_mday); + BOOST_CHECK_EQUAL(6, tmDate.tm_hour); + BOOST_CHECK_EQUAL(34, tmDate.tm_min); + BOOST_CHECK_EQUAL(51, tmDate.tm_sec); +} + +BOOST_AUTO_TEST_SUITE_END() http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/src/column_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/column_test.cpp b/modules/platforms/cpp/odbc-test/src/column_test.cpp new file mode 100644 index 0000000..4864a6a --- /dev/null +++ b/modules/platforms/cpp/odbc-test/src/column_test.cpp @@ -0,0 +1,290 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MSC_VER +# define BOOST_TEST_DYN_LINK +#endif + +#include <boost/test/unit_test.hpp> + +#include <ignite/impl/binary/binary_common.h> +#include <ignite/impl/binary/binary_writer_impl.h> + +#include "ignite/odbc/system/odbc_constants.h" +#include "ignite/odbc/column.h" + +using namespace ignite::impl::binary; +using namespace ignite::odbc::app; +using namespace ignite::odbc; + +BOOST_AUTO_TEST_SUITE(ColumnTestSuite) + +BOOST_AUTO_TEST_CASE(TestColumnDefaultConstruction) +{ + Column column; + + BOOST_REQUIRE(!column.IsValid()); +} + +BOOST_AUTO_TEST_CASE(TestColumnShort) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + int16_t data = 42; + + writer.WriteInt8(IGNITE_TYPE_SHORT); + writer.WriteInt16(data); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column(reader); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == 2); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 2); + + short shortBuf = 0; + SqlLen reslen = 0; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &shortBuf, sizeof(shortBuf), &reslen, &offset); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == 2); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(shortBuf == data); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == 2); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); +} + +BOOST_AUTO_TEST_CASE(TestColumnString) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + std::string data("Some test data."); + + writer.WriteString(data.data(), static_cast<int32_t>(data.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column(reader); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size()); + + char strBuf[1024] = {}; + SqlLen reslen = 0; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(std::string(strBuf) == data); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); +} + +BOOST_AUTO_TEST_CASE(TestColumnStringSeveral) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + std::string data("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + + writer.WriteString(data.data(), static_cast<int32_t>(data.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column(reader); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size()); + + std::string res; + + std::string strBuf(data.size() / 3 + 2, 0); + SqlLen reslen = 0; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf[0], strBuf.size(), &reslen, &offset); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - (strBuf.size() - 1)); + + res.append(strBuf.c_str()); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - 2 * (strBuf.size() - 1)); + + res.append(strBuf.c_str()); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + res.append(strBuf.c_str()); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(res == data); +} + +BOOST_AUTO_TEST_CASE(TestColumnMultiString) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + std::string data1("Some test data."); + std::string data2("Other TEST DATA."); + + writer.WriteString(data1.data(), static_cast<int32_t>(data1.size())); + writer.WriteString(data2.data(), static_cast<int32_t>(data2.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column1(reader); + + inStream.Position(column1.GetEndPosition()); + + Column column2(reader); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == data1.size()); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data2.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == data2.size()); + + char strBuf[1024] = {}; + SqlLen reslen = 0; + size_t* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset); + + BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(std::string(strBuf) == data1); + + BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data2.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(std::string(strBuf) == data2); + + BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data2.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == 0); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/src/configuration_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp new file mode 100644 index 0000000..85aa3ff --- /dev/null +++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp @@ -0,0 +1,224 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MSC_VER +# define BOOST_TEST_DYN_LINK +#endif + +#include <iostream> + +#include <boost/test/unit_test.hpp> + +#include <ignite/odbc/config/configuration.h> + +using namespace ignite::odbc::config; + +namespace +{ + const char* testDriverName = "Ignite"; + const char* testServerHost = "testhost.com"; + const uint16_t testServerPort = 4242; + const char* testCacheName = "TestCache"; + const char* testDsn = "Ignite DSN"; +} + +BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite) + +void CheckConnectionConfig(const Configuration& cfg) +{ + BOOST_REQUIRE(cfg.GetDriver() == testDriverName); + BOOST_REQUIRE(cfg.GetHost() == testServerHost); + BOOST_REQUIRE(cfg.GetPort() == testServerPort); + BOOST_REQUIRE(cfg.GetCache() == testCacheName); + BOOST_REQUIRE(cfg.GetDsn().empty()); + + std::stringstream constructor; + + constructor << "driver={" << testDriverName << "};" + << "server=" << testServerHost << ";" + << "port=" << testServerPort << ";" + << "cache=" << testCacheName << ";"; + + const std::string& expectedStr = constructor.str(); + + BOOST_REQUIRE(cfg.ToConnectString() == expectedStr); +} + +void CheckDsnConfig(const Configuration& cfg) +{ + BOOST_REQUIRE(cfg.GetDriver() == testDriverName); + BOOST_REQUIRE(cfg.GetDsn() == testDsn); + BOOST_REQUIRE(cfg.GetHost().empty()); + BOOST_REQUIRE(cfg.GetCache().empty()); + BOOST_REQUIRE(cfg.GetPort() == 0); +} + +BOOST_AUTO_TEST_CASE(TestConnectStringUppercase) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "DRIVER={" << testDriverName << "};" + << "SERVER=" << testServerHost <<";" + << "PORT=" << testServerPort << ";" + << "CACHE=" << testCacheName; + + const std::string& connectStr = constructor.str(); + + cfg.FillFromConnectString(connectStr.c_str(), connectStr.size()); + + CheckConnectionConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestConnectStringLowercase) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "driver={" << testDriverName << "};" + << "server=" << testServerHost << ";" + << "port=" << testServerPort << ";" + << "cache=" << testCacheName; + + const std::string& connectStr = constructor.str(); + + cfg.FillFromConnectString(connectStr.c_str(), connectStr.size()); + + CheckConnectionConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "driver={" << testDriverName << "};" + << "server=" << testServerHost << ";" + << "port=" << testServerPort << ";" + << "cache=" << testCacheName; + + const std::string& connectStr = constructor.str(); + + cfg.FillFromConnectString(connectStr.c_str(), connectStr.size() + 1); + + CheckConnectionConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestConnectStringMixed) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "Driver={" << testDriverName << "};" + << "Server=" << testServerHost << ";" + << "Port=" << testServerPort << ";" + << "Cache=" << testCacheName; + + const std::string& connectStr = constructor.str(); + + cfg.FillFromConnectString(connectStr.c_str(), connectStr.size()); + + CheckConnectionConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "DRIVER = {" << testDriverName << "} ;\n" + << " SERVER =" << testServerHost << " ; \n" + << "PORT= " << testServerPort << "; " + << "CACHE = \n\r" << testCacheName; + + const std::string& connectStr = constructor.str(); + + cfg.FillFromConnectString(connectStr.c_str(), connectStr.size()); + + CheckConnectionConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestDsnStringUppercase) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "DRIVER=" << testDriverName << '\0' + << "DSN={" << testDsn << "}" << '\0' << '\0'; + + const std::string& configStr = constructor.str(); + + cfg.FillFromConfigAttributes(configStr.data()); + + CheckDsnConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "driver=" << testDriverName << '\0' + << "dsn={" << testDsn << "}" << '\0' << '\0'; + + const std::string& configStr = constructor.str(); + + cfg.FillFromConfigAttributes(configStr.data()); + + CheckDsnConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestDsnStrinMixed) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << "Driver=" << testDriverName << '\0' + << "Dsn={" << testDsn << "}" << '\0' << '\0'; + + const std::string& configStr = constructor.str(); + + cfg.FillFromConfigAttributes(configStr.data()); + + CheckDsnConfig(cfg); +} + +BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces) +{ + Configuration cfg; + + std::stringstream constructor; + + constructor << " DRIVER = " << testDriverName << "\r\n" << '\0' + << "DSN= {" << testDsn << "} \n" << '\0' << '\0'; + + const std::string& configStr = constructor.str(); + + cfg.FillFromConfigAttributes(configStr.data()); + + CheckDsnConfig(cfg); +} + +BOOST_AUTO_TEST_SUITE_END() http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp b/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp new file mode 100644 index 0000000..dd8d1f6 --- /dev/null +++ b/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp @@ -0,0 +1,219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MSC_VER +# define BOOST_TEST_DYN_LINK +#endif + +#include <iostream> + +#include <boost/test/unit_test.hpp> + +#include "ignite/odbc/system/odbc_constants.h" +#include "ignite/odbc/config/connection_info.h" + +using namespace ignite::odbc; +using namespace ignite::odbc::config; + +BOOST_AUTO_TEST_SUITE(ConnectionInfoTestSuite) + +BOOST_AUTO_TEST_CASE(TestConnectionInfoSupportedInfo) +{ + char buffer[4096]; + short reslen = 0; + + ConnectionInfo info; + + SqlResult result; + +#ifdef SQL_DRIVER_NAME + result = info.GetInfo(SQL_DRIVER_NAME, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DRIVER_NAME + +#ifdef SQL_DBMS_NAME + result = info.GetInfo(SQL_DBMS_NAME, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DBMS_NAME + +#ifdef SQL_DRIVER_ODBC_VER + result = info.GetInfo(SQL_DRIVER_ODBC_VER, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DRIVER_ODBC_VER + +#ifdef SQL_DBMS_VER + result = info.GetInfo(SQL_DBMS_VER, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DBMS_VER + +#ifdef SQL_DRIVER_VER + result = info.GetInfo(SQL_DRIVER_VER, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DRIVER_VER + +#ifdef SQL_COLUMN_ALIAS + result = info.GetInfo(SQL_COLUMN_ALIAS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_COLUMN_ALIAS + +#ifdef SQL_IDENTIFIER_QUOTE_CHAR + result = info.GetInfo(SQL_IDENTIFIER_QUOTE_CHAR, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_IDENTIFIER_QUOTE_CHAR + +#ifdef SQL_CATALOG_NAME_SEPARATOR + result = info.GetInfo(SQL_CATALOG_NAME_SEPARATOR, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CATALOG_NAME_SEPARATOR + +#ifdef SQL_SPECIAL_CHARACTERS + result = info.GetInfo(SQL_SPECIAL_CHARACTERS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_SPECIAL_CHARACTERS + +#ifdef SQL_CATALOG_TERM + result = info.GetInfo(SQL_CATALOG_TERM, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CATALOG_TERM + +#ifdef SQL_TABLE_TERM + result = info.GetInfo(SQL_TABLE_TERM, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_TABLE_TERM + +#ifdef SQL_SCHEMA_TERM + result = info.GetInfo(SQL_SCHEMA_TERM, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_SCHEMA_TERM + +#ifdef SQL_ASYNC_DBC_FUNCTIONS + result = info.GetInfo(SQL_ASYNC_DBC_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_ASYNC_DBC_FUNCTIONS + +#ifdef SQL_GETDATA_EXTENSIONS + result = info.GetInfo(SQL_GETDATA_EXTENSIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_GETDATA_EXTENSIONS + +#ifdef SQL_ODBC_INTERFACE_CONFORMANCE + result = info.GetInfo(SQL_ODBC_INTERFACE_CONFORMANCE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_ODBC_INTERFACE_CONFORMANCE + +#ifdef SQL_SQL_CONFORMANCE + result = info.GetInfo(SQL_SQL_CONFORMANCE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_SQL_CONFORMANCE + +#ifdef SQL_CATALOG_USAGE + result = info.GetInfo(SQL_CATALOG_USAGE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CATALOG_USAGE + +#ifdef SQL_SCHEMA_USAGE + result = info.GetInfo(SQL_SCHEMA_USAGE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_SCHEMA_USAGE + +#ifdef SQL_MAX_IDENTIFIER_LEN + result = info.GetInfo(SQL_MAX_IDENTIFIER_LEN, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_MAX_IDENTIFIER_LEN + +#ifdef SQL_AGGREGATE_FUNCTIONS + result = info.GetInfo(SQL_AGGREGATE_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_AGGREGATE_FUNCTIONS + +#ifdef SQL_AGGREGATE_FUNCTIONS + result = info.GetInfo(SQL_NUMERIC_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_AGGREGATE_FUNCTIONS + +#ifdef SQL_STRING_FUNCTIONS + result = info.GetInfo(SQL_STRING_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_STRING_FUNCTIONS + +#ifdef SQL_TIMEDATE_FUNCTIONS + result = info.GetInfo(SQL_TIMEDATE_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_TIMEDATE_FUNCTIONS + +#ifdef SQL_TIMEDATE_ADD_INTERVALS + result = info.GetInfo(SQL_TIMEDATE_ADD_INTERVALS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_TIMEDATE_ADD_INTERVALS + +#ifdef SQL_TIMEDATE_DIFF_INTERVALS + result = info.GetInfo(SQL_TIMEDATE_DIFF_INTERVALS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_TIMEDATE_DIFF_INTERVALS + +#ifdef SQL_DATETIME_LITERALS + result = info.GetInfo(SQL_DATETIME_LITERALS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_DATETIME_LITERALS + +#ifdef SQL_SYSTEM_FUNCTIONS + result = info.GetInfo(SQL_SYSTEM_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_SYSTEM_FUNCTIONS + +#ifdef SQL_CONVERT_FUNCTIONS + result = info.GetInfo(SQL_CONVERT_FUNCTIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CONVERT_FUNCTIONS + +#ifdef SQL_OJ_CAPABILITIES + result = info.GetInfo(SQL_OJ_CAPABILITIES, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_OJ_CAPABILITIES + +#ifdef SQL_POS_OPERATIONS + result = info.GetInfo(SQL_POS_OPERATIONS, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_POS_OPERATIONS + +#ifdef SQL_MAX_CONCURRENT_ACTIVITIES + result = info.GetInfo(SQL_MAX_CONCURRENT_ACTIVITIES, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_MAX_CONCURRENT_ACTIVITIES + +#ifdef SQL_CURSOR_COMMIT_BEHAVIOR + result = info.GetInfo(SQL_CURSOR_COMMIT_BEHAVIOR, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CURSOR_COMMIT_BEHAVIOR + +#ifdef SQL_CURSOR_ROLLBACK_BEHAVIOR + result = info.GetInfo(SQL_CURSOR_ROLLBACK_BEHAVIOR, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_CURSOR_ROLLBACK_BEHAVIOR + +#ifdef SQL_TXN_CAPABLE + result = info.GetInfo(SQL_TXN_CAPABLE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_TXN_CAPABLE + +#ifdef SQL_QUOTED_IDENTIFIER_CASE + result = info.GetInfo(SQL_QUOTED_IDENTIFIER_CASE, buffer, sizeof(buffer), &reslen); + BOOST_REQUIRE(result == SQL_RESULT_SUCCESS); +#endif //SQL_QUOTED_IDENTIFIER_CASE +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
