You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2017/03/21 11:54:53 UTC
[1/2] ignite git commit: IGNITE-4690: CPP: Added ignite::Time type
Repository: ignite
Updated Branches:
refs/heads/master 19ba8f477 -> 02991d306
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
index f2b3d33..9e610e6 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
@@ -171,216 +171,54 @@ void CheckRawPrimitiveArray(T dflt, T val1, T val2)
void CheckRawWritesRestricted(BinaryRawWriter& writer)
{
- try
- {
- writer.WriteInt8(1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- int8_t arr[1];
-
- writer.WriteInt8Array(arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Guid val(1, 1);
-
- writer.WriteGuid(val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Date val(1);
-
- writer.WriteDate(val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Timestamp val(1);
-
- writer.WriteTimestamp(val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteString("test");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteArray<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteCollection<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteMap<int8_t, int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteInt8(1), IgniteError, IsBinaryError);
+
+ int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(writer.WriteInt8Array(arr, 1), IgniteError, IsBinaryError);
+
+ Guid guid(1, 1);
+ BOOST_CHECK_EXCEPTION(writer.WriteGuid(guid), IgniteError, IsBinaryError);
+
+ Date date(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteDate(date), IgniteError, IsBinaryError);
+
+ Time time(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteTime(time), IgniteError, IsBinaryError);
+
+ Timestamp ts(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteTimestamp(ts), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(writer.WriteString("test"), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(writer.WriteArray<int8_t>(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(writer.WriteCollection<int8_t>(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION((writer.WriteMap<int8_t, int8_t>()), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(writer.WriteInt8(1), IgniteError, IsBinaryError);
}
void CheckRawReadsRestricted(BinaryRawReader& reader)
{
- try
- {
- reader.ReadInt8();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- int8_t arr[1];
-
- reader.ReadInt8Array(arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadGuid();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadDate();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadTimestamp();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadString();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadArray<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadCollection<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadMap<int8_t, int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadInt8(), IgniteError, IsBinaryError);
+
+ int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(reader.ReadInt8Array(arr, 1), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadGuid(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadDate(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadTimestamp(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadString(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadArray<int8_t>(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadCollection<int8_t>(), IgniteError, IsBinaryError);
+
+ BOOST_CHECK_EXCEPTION((reader.ReadMap<int8_t, int8_t>()), IgniteError, IsBinaryError);
}
void CheckRawCollectionEmpty(CollectionType* colType)
@@ -400,27 +238,9 @@ void CheckRawCollectionEmpty(CollectionType* colType)
rawWriter.WriteInt8(1);
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Write(1), IgniteError, IsBinaryError);
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -439,16 +259,7 @@ void CheckRawCollectionEmpty(CollectionType* colType)
BOOST_REQUIRE(!colReader.HasNext());
BOOST_REQUIRE(!colReader.IsNull());
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -478,27 +289,9 @@ void CheckRawCollection(CollectionType* colType)
rawWriter.WriteInt8(1);
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Write(1), IgniteError, IsBinaryError);
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -529,16 +322,7 @@ void CheckRawCollection(CollectionType* colType)
BOOST_REQUIRE(!colReader.HasNext());
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -609,27 +393,9 @@ void CheckRawMapEmpty(MapType* mapType)
rawWriter.WriteInt8(1);
- try
- {
- mapWriter.Write(1, BinaryInner(1));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapWriter.Write(1, BinaryInner(1)), IgniteError, IsBinaryError);
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -648,19 +414,9 @@ void CheckRawMapEmpty(MapType* mapType)
BOOST_REQUIRE(!mapReader.HasNext());
BOOST_REQUIRE(!mapReader.IsNull());
- try
- {
- int8_t key;
- BinaryInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ int8_t key;
+ BinaryInner val;
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -690,27 +446,9 @@ void CheckRawMap(MapType* mapType)
rawWriter.WriteInt8(1);
- try
- {
- mapWriter.Write(4, BinaryInner(4));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- mapWriter.Close();
+ BOOST_CHECK_EXCEPTION(mapWriter.Write(4, BinaryInner(4)), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -749,16 +487,7 @@ void CheckRawMap(MapType* mapType)
BOOST_REQUIRE(!mapReader.HasNext());
- try
- {
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -819,6 +548,13 @@ BOOST_AUTO_TEST_CASE(TestPrimitiveDate)
CheckRawPrimitive<Date>(val);
}
+BOOST_AUTO_TEST_CASE(TestPrimitiveTime)
+{
+ Time val(time(NULL) * 1000);
+
+ CheckRawPrimitive<Time>(val);
+}
+
BOOST_AUTO_TEST_CASE(TestPrimitiveTimestamp)
{
Timestamp val(time(NULL), 0);
@@ -884,6 +620,15 @@ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDate)
CheckRawPrimitiveArray<Date>(dflt, val1, val2);
}
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayTime)
+{
+ Time dflt(1);
+ Time val1(2);
+ Time val2(3);
+
+ CheckRawPrimitiveArray<Time>(dflt, val1, val2);
+}
+
BOOST_AUTO_TEST_CASE(TestPrimitiveArrayTimestamp)
{
Timestamp dflt(1);
@@ -937,6 +682,28 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
BOOST_REQUIRE(actualVal == expVal);
}
+BOOST_AUTO_TEST_CASE(TestTimeNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ Time expVal;
+ Time actualVal = rawReader.ReadTime();
+
+ BOOST_REQUIRE(actualVal == expVal);
+}
+
BOOST_AUTO_TEST_CASE(TestTimestampNull)
{
InteropUnpooledMemory mem(1024);
@@ -1030,29 +797,10 @@ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(arrReader.IsNull());
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1073,55 +821,14 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
rawWriter.WriteInt8(1);
- try
- {
- const char* val = "test";
+ const char* val1 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1, 4), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1), IgniteError, IsBinaryError);
- arrWriter.Write(val, 4);
+ std::string val2 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val2), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -1135,29 +842,9 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(!arrReader.IsNull());
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1188,55 +875,14 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
rawWriter.WriteInt8(1);
- try
- {
- const char* val = "test";
+ const char* val1 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1, 4), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1), IgniteError, IsBinaryError);
- arrWriter.Write(val, 4);
+ std::string val2 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val2), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -1298,29 +944,9 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
BOOST_REQUIRE(!arrReader.HasNext());
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1413,16 +1039,7 @@ BOOST_AUTO_TEST_CASE(TestArrayNull)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(arrReader.IsNull());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1443,27 +1060,9 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
rawWriter.WriteInt8(1);
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -1477,16 +1076,7 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(!arrReader.IsNull());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1515,27 +1105,9 @@ BOOST_AUTO_TEST_CASE(TestArray)
rawWriter.WriteInt8(1);
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
out.Synchronize();
@@ -1561,16 +1133,7 @@ BOOST_AUTO_TEST_CASE(TestArray)
BOOST_REQUIRE(!arrReader.HasNext());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1599,16 +1162,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionNull)
BOOST_REQUIRE(!colReader.HasNext());
BOOST_REQUIRE(colReader.IsNull());
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
@@ -1673,19 +1227,9 @@ BOOST_AUTO_TEST_CASE(TestMapNull)
BOOST_REQUIRE(!mapReader.HasNext());
BOOST_REQUIRE(mapReader.IsNull());
- try
- {
- int8_t key;
- BinaryInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ int8_t key;
+ BinaryInner val;
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index dd5743a..3115764 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -46,16 +46,7 @@ void CheckPrimitive(T val)
BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
BinaryWriter writer(&writerImpl);
- try
- {
- Write<T>(writer, NULL, val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(Write<T>(writer, NULL, val), IgniteError, IsBinaryError);
Write<T>(writer, "test", val);
@@ -73,27 +64,11 @@ void CheckPrimitive(T val)
BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
- try
- {
- Read<T>(reader, NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(Read<T>(reader, NULL), IgniteError, IsBinaryError);
- try
- {
- T readVal = Read<T>(reader, "test");
+ T readVal = Read<T>(reader, "test");
- BOOST_REQUIRE(readVal == val);
- }
- catch (IgniteError& err)
- {
- BOOST_FAIL(err.GetText());
- }
+ BOOST_REQUIRE(readVal == val);
}
template<typename T>
@@ -111,21 +86,12 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
out.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- T nullFieldArr[2];
+ T nullFieldArr[2];
- nullFieldArr[0] = val1;
- nullFieldArr[1] = val2;
+ nullFieldArr[0] = val1;
+ nullFieldArr[1] = val2;
- WriteArray<T>(writer, NULL, nullFieldArr, 2);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(WriteArray<T>(writer, NULL, nullFieldArr, 2), IgniteError, IsBinaryError);
T arr1[2];
arr1[0] = dflt;
@@ -269,16 +235,7 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
in.Position(IGNITE_DFLT_HDR_LEN);
BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 2);
- try
- {
- ReadArray<T>(reader, NULL, arr1, 2);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(ReadArray<T>(reader, NULL, arr1, 2), IgniteError, IsBinaryError);
BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 2);
BOOST_REQUIRE(arr1[0] == dflt);
@@ -296,216 +253,52 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
void CheckWritesRestricted(BinaryWriter& writer)
{
- try
- {
- writer.WriteInt8("field", 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(writer.WriteInt8("field", 1), IgniteError, IsBinaryError);
- writer.WriteInt8Array("field", arr, 1);
+ int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(writer.WriteInt8Array("field", arr, 1), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Guid val(1, 1);
-
- writer.WriteGuid("field", val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Date val(1);
-
- writer.WriteDate("field", val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- Timestamp val(1);
-
- writer.WriteTimestamp("field", val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteString("field", "test");
+ Guid guid(1, 1);
+ BOOST_CHECK_EXCEPTION(writer.WriteGuid("field", guid), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ Date date(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteDate("field", date), IgniteError, IsBinaryError);
- try
- {
- writer.WriteArray<int8_t>("field");
+ Time time(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteTime("field", time), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ Timestamp ts(1);
+ BOOST_CHECK_EXCEPTION(writer.WriteTimestamp("field", ts), IgniteError, IsBinaryError);
- try
- {
- writer.WriteCollection<int8_t>("field");
+ BOOST_CHECK_EXCEPTION(writer.WriteString("field", "test"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteArray<int8_t>("field"), IgniteError, IsBinaryError);
- try
- {
- writer.WriteMap<int8_t, int8_t>("field");
+ BOOST_CHECK_EXCEPTION(writer.WriteCollection<int8_t>("field"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION((writer.WriteMap<int8_t, int8_t>("field")), IgniteError, IsBinaryError);
}
void CheckReadsRestricted(BinaryReader& reader)
{
- try
- {
- reader.ReadInt8("field");
+ BOOST_CHECK_EXCEPTION(reader.ReadInt8("field"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(reader.ReadInt8Array("field", arr, 1), IgniteError, IsBinaryError);
- try
- {
- int8_t arr[1];
+ BOOST_CHECK_EXCEPTION(reader.ReadGuid("field"), IgniteError, IsBinaryError);
- reader.ReadInt8Array("field", arr, 1);
+ BOOST_CHECK_EXCEPTION(reader.ReadDate("field"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadTimestamp("field"), IgniteError, IsBinaryError);
- try
- {
- reader.ReadGuid("field");
+ BOOST_CHECK_EXCEPTION(reader.ReadString("field"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadArray<int8_t>("field"), IgniteError, IsBinaryError);
- try
- {
- reader.ReadDate("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadTimestamp("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadString("field");
+ BOOST_CHECK_EXCEPTION(reader.ReadCollection<int8_t>("field"), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadArray<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadCollection<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadMap<int8_t, int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION((reader.ReadMap<int8_t, int8_t>("field")), IgniteError, IsBinaryError);
}
void CheckCollectionEmpty(CollectionType* colType)
@@ -529,27 +322,9 @@ void CheckCollectionEmpty(CollectionType* colType)
writer.WriteInt8("field2", 1);
- try
- {
- colWriter.Write(1);
+ BOOST_CHECK_EXCEPTION(colWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -575,17 +350,8 @@ void CheckCollectionEmpty(CollectionType* colType)
BOOST_REQUIRE(colReader.GetSize() == 0);
BOOST_REQUIRE(!colReader.HasNext());
BOOST_REQUIRE(!colReader.IsNull());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -619,27 +385,9 @@ void CheckCollection(CollectionType* colType)
writer.WriteInt8("field2", 1);
- try
- {
- colWriter.Write(1);
+ BOOST_CHECK_EXCEPTION(colWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -678,16 +426,7 @@ void CheckCollection(CollectionType* colType)
BOOST_REQUIRE(!colReader.HasNext());
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -772,27 +511,9 @@ void CheckMapEmpty(MapType* mapType)
writer.WriteInt8("field2", 1);
- try
- {
- mapWriter.Write(1, BinaryInner(1));
+ BOOST_CHECK_EXCEPTION(mapWriter.Write(1, BinaryInner(1)), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -819,19 +540,9 @@ void CheckMapEmpty(MapType* mapType)
BOOST_REQUIRE(!mapReader.HasNext());
BOOST_REQUIRE(!mapReader.IsNull());
- try
- {
- int8_t key;
- BinaryInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ int8_t key;
+ BinaryInner val;
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -865,27 +576,9 @@ void CheckMap(MapType* mapType)
writer.WriteInt8("field2", 1);
- try
- {
- mapWriter.Write(4, BinaryInner(4));
+ BOOST_CHECK_EXCEPTION(mapWriter.Write(4, BinaryInner(4)), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -932,16 +625,7 @@ void CheckMap(MapType* mapType)
BOOST_REQUIRE(!mapReader.HasNext());
- try
- {
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1002,6 +686,13 @@ BOOST_AUTO_TEST_CASE(TestPrimitiveDate)
CheckPrimitive<Date>(val);
}
+BOOST_AUTO_TEST_CASE(TestPrimitiveTime)
+{
+ Time val(time(NULL) * 1000);
+
+ CheckPrimitive<Time>(val);
+}
+
BOOST_AUTO_TEST_CASE(TestPrimitiveTimestamp)
{
Timestamp val(time(NULL), 0);
@@ -1067,6 +758,15 @@ BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDate)
CheckPrimitiveArray<Date>(dflt, val1, val2);
}
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayTime)
+{
+ Time dflt(1);
+ Time val1(2);
+ Time val2(3);
+
+ CheckPrimitiveArray<Time>(dflt, val1, val2);
+}
+
BOOST_AUTO_TEST_CASE(TestPrimitiveArrayTimestamp)
{
Timestamp dflt(1);
@@ -1088,16 +788,7 @@ BOOST_AUTO_TEST_CASE(TestGuidNull)
out.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- writer.WriteNull(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteNull(NULL), IgniteError, IsBinaryError);
writer.WriteNull("test");
@@ -1115,16 +806,7 @@ BOOST_AUTO_TEST_CASE(TestGuidNull)
in.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- reader.ReadGuid(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadGuid(NULL), IgniteError, IsBinaryError);
Guid expVal;
Guid actualVal = reader.ReadGuid("test");
@@ -1144,16 +826,7 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
out.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- writer.WriteNull(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteNull(NULL), IgniteError, IsBinaryError);
writer.WriteNull("test");
@@ -1171,16 +844,7 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
in.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- reader.ReadDate(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadDate(NULL), IgniteError, IsBinaryError);
Date expVal;
Date actualVal = reader.ReadDate("test");
@@ -1188,7 +852,7 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
BOOST_REQUIRE(actualVal == expVal);
}
-BOOST_AUTO_TEST_CASE(TestTimestampNull)
+BOOST_AUTO_TEST_CASE(TestTimeNull)
{
TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
@@ -1200,16 +864,7 @@ BOOST_AUTO_TEST_CASE(TestTimestampNull)
out.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- writer.WriteNull(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteNull(NULL), IgniteError, IsBinaryError);
writer.WriteNull("test");
@@ -1227,16 +882,45 @@ BOOST_AUTO_TEST_CASE(TestTimestampNull)
in.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- reader.ReadTimestamp(NULL);
+ BOOST_CHECK_EXCEPTION(reader.ReadTime(NULL), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ Time expVal;
+ Time actualVal = reader.ReadTime("test");
+
+ BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestTimestampNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BOOST_CHECK_EXCEPTION(writer.WriteNull(NULL), IgniteError, IsBinaryError);
+
+ writer.WriteNull("test");
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BOOST_CHECK_EXCEPTION(reader.ReadTimestamp(NULL), IgniteError, IsBinaryError);
Timestamp expVal;
Timestamp actualVal = reader.ReadTimestamp("test");
@@ -1259,38 +943,11 @@ BOOST_AUTO_TEST_CASE(TestString) {
const char* writeVal2 = "test";
std::string writeVal3 = writeVal1;
- try
- {
- writer.WriteString(NULL, writeVal1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteString(NULL, writeVal1), IgniteError, IsBinaryError);
- try
- {
- writer.WriteString(NULL, writeVal1, 4);
+ BOOST_CHECK_EXCEPTION(writer.WriteString(NULL, writeVal1, 4), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- writer.WriteString(NULL, writeVal3);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.WriteString(NULL, writeVal3), IgniteError, IsBinaryError);
writer.WriteString("field1", writeVal1);
writer.WriteString("field2", writeVal1, 4);
@@ -1312,29 +969,10 @@ BOOST_AUTO_TEST_CASE(TestString) {
in.Position(IGNITE_DFLT_HDR_LEN);
- try
- {
- char nullCheckRes[9];
-
- reader.ReadString(NULL, nullCheckRes, 9);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- reader.ReadString(NULL);
+ char nullCheckRes[9];
+ BOOST_CHECK_EXCEPTION(reader.ReadString(NULL, nullCheckRes, 9), IgniteError, IsBinaryError);
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadString(NULL), IgniteError, IsBinaryError);
char readVal1[9];
char readVal2[5];
@@ -1396,29 +1034,9 @@ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(arrReader.IsNull());
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1443,55 +1061,14 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
writer.WriteInt8("field2", 1);
- try
- {
- const char* val = "test";
+ const char* val1 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1, 4), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1), IgniteError, IsBinaryError);
- arrWriter.Write(val, 4);
+ std::string val2 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val2), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -1513,29 +1090,10 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(!arrReader.IsNull());
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1570,55 +1128,14 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
writer.WriteInt8("field2", 1);
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val, 4);
+ const char* val1 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1, 4), IgniteError, IsBinaryError);
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ std::string val2 = "test";
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(val2), IgniteError, IsBinaryError);
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -1688,29 +1205,10 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
BOOST_REQUIRE(!arrReader.HasNext());
- try
- {
- char res[100];
+ char res[100];
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(res, 100), IgniteError, IsBinaryError);
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1840,16 +1338,7 @@ BOOST_AUTO_TEST_CASE(TestArrayNull)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(arrReader.IsNull());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1874,27 +1363,9 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
writer.WriteInt8("field2", 1);
- try
- {
- arrWriter.Write(1);
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -1916,16 +1387,7 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
BOOST_REQUIRE(!arrReader.HasNext());
BOOST_REQUIRE(!arrReader.IsNull());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -1958,27 +1420,9 @@ BOOST_AUTO_TEST_CASE(TestArray)
writer.WriteInt8("field2", 1);
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
-
- try
- {
- arrWriter.Close();
+ BOOST_CHECK_EXCEPTION(arrWriter.Write(1), IgniteError, IsBinaryError);
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrWriter.Close(), IgniteError, IsBinaryError);
writerImpl.PostWrite();
@@ -2012,16 +1456,7 @@ BOOST_AUTO_TEST_CASE(TestArray)
BOOST_REQUIRE(!arrReader.HasNext());
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(arrReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -2060,18 +1495,9 @@ BOOST_AUTO_TEST_CASE(TestCollectionNull)
BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
BOOST_REQUIRE(colReader.GetSize() == -1);
BOOST_REQUIRE(!colReader.HasNext());
- BOOST_REQUIRE(colReader.IsNull());
-
- try
- {
- colReader.GetNext();
+ BOOST_REQUIRE(colReader.IsNull());
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -2148,19 +1574,9 @@ BOOST_AUTO_TEST_CASE(TestMapNull)
BOOST_REQUIRE(!mapReader.HasNext());
BOOST_REQUIRE(mapReader.IsNull());
- try
- {
- int8_t key;
- BinaryInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ int8_t key;
+ BinaryInner val;
+ BOOST_CHECK_EXCEPTION(mapReader.GetNext(&key, &val), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
}
@@ -2203,16 +1619,7 @@ BOOST_AUTO_TEST_CASE(TestRawMode)
BinaryRawWriter rawWriter = writer.RawWriter();
- try
- {
- writer.RawWriter();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(writer.RawWriter(), IgniteError, IsBinaryError);
rawWriter.WriteInt8(1);
@@ -2234,16 +1641,7 @@ BOOST_AUTO_TEST_CASE(TestRawMode)
BinaryRawReader rawReader = reader.RawReader();
- try
- {
- reader.RawReader();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.RawReader(), IgniteError, IsBinaryError);
BOOST_REQUIRE(rawReader.ReadInt8() == 1);
@@ -2345,16 +1743,7 @@ BOOST_AUTO_TEST_CASE(TestFieldSeek)
in.Position(IGNITE_DFLT_HDR_LEN);
BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- try
- {
- reader.ReadInt64("val2");
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
- }
+ BOOST_CHECK_EXCEPTION(reader.ReadInt64("val2"), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/binary_session_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_session_test.cpp b/modules/platforms/cpp/core-test/src/binary_session_test.cpp
index 0b9b34d..08bc1eb 100644
--- a/modules/platforms/cpp/core-test/src/binary_session_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_session_test.cpp
@@ -155,6 +155,24 @@ BOOST_AUTO_TEST_CASE(TestDate)
BOOST_REQUIRE(readVal == writeVal);
}
+BOOST_AUTO_TEST_CASE(TestTime)
+{
+ Time writeVal = Time(42);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writeSes(&out, NULL);
+ writeSes.WriteTopObject<Time>(writeVal);
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ Time readVal = reader.ReadTopObject<Time>();
+
+ BOOST_REQUIRE(readVal == writeVal);
+}
+
BOOST_AUTO_TEST_CASE(TestTimestamp)
{
Timestamp writeVal = Timestamp(77);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index 28eb3fd..abb374a 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -1130,30 +1130,23 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryExceptions)
cursor = cache.Query(qry);
- try
- {
- BOOST_REQUIRE(cursor.HasNext());
+ BOOST_REQUIRE(cursor.HasNext());
- QueryFieldsRow row = cursor.GetNext();
+ QueryFieldsRow row = cursor.GetNext();
- BOOST_REQUIRE(row.HasNext());
+ BOOST_REQUIRE(row.HasNext());
- int age = row.GetNext<int>();
+ int age = row.GetNext<int>();
- BOOST_REQUIRE(age == 10);
+ BOOST_REQUIRE(age == 10);
- std::string name = row.GetNext<std::string>();
+ std::string name = row.GetNext<std::string>();
- BOOST_REQUIRE(name == "A1");
+ BOOST_REQUIRE(name == "A1");
- BOOST_REQUIRE(!row.HasNext());
+ BOOST_REQUIRE(!row.HasNext());
- CheckEmpty(cursor);
- }
- catch (IgniteError& error)
- {
- BOOST_FAIL(error.GetText());
- }
+ CheckEmpty(cursor);
}
/**
@@ -1639,6 +1632,46 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestampEqual)
}
/**
+ * Test query for Time type.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryTimeEqual)
+{
+ // Test simple query.
+ Cache<int, Time> cache = grid.GetOrCreateCache<int, Time>("TimeCache");
+
+ // Test query with field of type 'Timestamp'.
+ SqlFieldsQuery qry("select _key from Time where _val='04:11:02'");
+
+ QueryFieldsCursor cursor = cache.Query(qry);
+ CheckEmpty(cursor);
+
+ int32_t entryCnt = 1000; // Number of entries.
+
+ for (int i = 0; i < entryCnt; i++)
+ {
+ int secs = i % 60;
+ int mins = i / 60;
+ cache.Put(i, MakeTimeGmt(4, mins, secs));
+ }
+
+ cursor = cache.Query(qry);
+
+ BOOST_REQUIRE(cursor.HasNext());
+
+ QueryFieldsRow row = cursor.GetNext();
+
+ BOOST_REQUIRE(row.HasNext());
+
+ int key = row.GetNext<int>();
+
+ BOOST_CHECK(key == 662);
+
+ BOOST_REQUIRE(!row.HasNext());
+
+ CheckEmpty(cursor);
+}
+
+/**
* Test fields query with several pages.
*/
BOOST_AUTO_TEST_CASE(TestFieldsQueryPagesSeveral)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index f38eecc..437ed234 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -452,6 +452,18 @@ BOOST_AUTO_TEST_CASE(TestPutGetDate)
BOOST_REQUIRE(now == cache.Get(5));
}
+BOOST_AUTO_TEST_CASE(TestPutGetTime)
+{
+ // Get existing cache
+ cache::Cache<int, Time> cache = grid0.GetOrCreateCache<int, Time>("partitioned");
+
+ Time now = Time(time(NULL) * 1000);
+
+ cache.Put(5, now);
+
+ BOOST_REQUIRE(now == cache.Get(5));
+}
+
BOOST_AUTO_TEST_CASE(TestPutGetTimestamp)
{
// Get existing cache
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/date_time_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/date_time_test.cpp b/modules/platforms/cpp/core-test/src/date_time_test.cpp
new file mode 100644
index 0000000..0c93a17
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/date_time_test.cpp
@@ -0,0 +1,265 @@
+/*
+ * 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/time.h>
+#include <ignite/date.h>
+#include <ignite/timestamp.h>
+
+#include <ignite/common/utils.h>
+
+#include <ignite/test_utils.h>
+
+using namespace ignite;
+using namespace cache;
+using namespace boost::unit_test;
+
+/**
+ * Check operators for type.
+ * All args should refer to a different instances.
+ * Also, val1 should be less then val2 and equeal val3.
+ */
+template<typename T>
+void CheckOperators(const T& val1, const T& val2, const T& val3)
+{
+ BOOST_CHECK(&val1 != &val2);
+ BOOST_CHECK(&val1 != &val3);
+ BOOST_CHECK(&val2 != &val3);
+
+ BOOST_CHECK(val1 == val1);
+ BOOST_CHECK(val2 == val2);
+
+ BOOST_CHECK(val1 == val3);
+ BOOST_CHECK(val3 == val1);
+
+ BOOST_CHECK(val1 != val2);
+ BOOST_CHECK(val2 != val1);
+ BOOST_CHECK(val3 != val2);
+ BOOST_CHECK(val2 != val3);
+
+ BOOST_CHECK(val1 < val2);
+ BOOST_CHECK(val3 < val2);
+
+ BOOST_CHECK(val1 <= val2);
+ BOOST_CHECK(val3 <= val2);
+ BOOST_CHECK(val1 <= val1);
+ BOOST_CHECK(val2 <= val2);
+ BOOST_CHECK(val1 <= val3);
+ BOOST_CHECK(val3 <= val1);
+
+ BOOST_CHECK(val2 > val1);
+ BOOST_CHECK(val2 > val3);
+
+ BOOST_CHECK(val2 >= val1);
+ BOOST_CHECK(val2 >= val3);
+ BOOST_CHECK(val1 >= val1);
+ BOOST_CHECK(val2 >= val2);
+ BOOST_CHECK(val1 >= val3);
+ BOOST_CHECK(val3 >= val1);
+}
+
+void CheckDate(int year, int mon, int day)
+{
+ Date date = common::MakeDateGmt(year, mon, day);
+ tm res;
+
+ common::DateToCTm(date, res);
+
+ BOOST_CHECK_EQUAL(res.tm_year + 1900, year);
+ BOOST_CHECK_EQUAL(res.tm_mon + 1, mon);
+ BOOST_CHECK_EQUAL(res.tm_mday, day);
+}
+
+void CheckTimestamp(int year, int mon, int day, int hour, int mins, int sec, int ns)
+{
+ Timestamp ts = common::MakeTimestampGmt(year, mon, day, hour, mins, sec, ns);
+ tm res;
+
+ common::TimestampToCTm(ts, res);
+
+ BOOST_CHECK_EQUAL(res.tm_year + 1900, year);
+ BOOST_CHECK_EQUAL(res.tm_mon + 1, mon);
+ BOOST_CHECK_EQUAL(res.tm_mday, day);
+ BOOST_CHECK_EQUAL(res.tm_hour, hour);
+ BOOST_CHECK_EQUAL(res.tm_min, mins);
+ BOOST_CHECK_EQUAL(res.tm_sec, sec);
+}
+
+BOOST_AUTO_TEST_SUITE(DateTimeTestSuite)
+
+BOOST_AUTO_TEST_CASE(TimeOperators1)
+{
+ Time val1(1);
+ Time val2(2);
+ Time val3(1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimeOperators2)
+{
+ Time val1(154362);
+ Time val2(val1.GetMilliseconds() + 42363);
+ Time val3(val1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(DateOperators1)
+{
+ Date val1(1);
+ Date val2(2);
+ Date val3(1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(DateOperators2)
+{
+ Date val1(154362);
+ Date val2(val1.GetMilliseconds() + 42363);
+ Date val3(val1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimestampOperators1)
+{
+ Timestamp val1(1);
+ Timestamp val2(2);
+ Timestamp val3(1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimestampOperators2)
+{
+ Timestamp val1(154362);
+ Timestamp val2(val1.GetMilliseconds() + 42363);
+ Timestamp val3(val1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimestampOperators3)
+{
+ Timestamp val1(42, 1);
+ Timestamp val2(42, 2);
+ Timestamp val3(42, 1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimestampOperators4)
+{
+ Timestamp val1(42, 154362);
+ Timestamp val2(42, val1.GetSecondFraction() + 42363);
+ Timestamp val3(42, val1.GetSecondFraction());
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(TimestampOperators5)
+{
+ Timestamp val1(154362, 154362);
+ Timestamp val2(val1.GetMilliseconds() + 42363, val1.GetSecondFraction() + 42363);
+ Timestamp val3(val1);
+
+ CheckOperators(val1, val2, val3);
+}
+
+BOOST_AUTO_TEST_CASE(MakeTime)
+{
+ using namespace common;
+
+ BOOST_CHECK_EQUAL(MakeTimeGmt(0, 0, 0).GetMilliseconds(), 0);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(23, 59, 59).GetMilliseconds(), 86399000);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(14, 23, 47).GetMilliseconds(), 51827000);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(0, 24, 12).GetMilliseconds(), 1452000);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(8, 0, 0).GetMilliseconds(), 28800000);
+
+ BOOST_CHECK_EQUAL(MakeTimeGmt(0, 0, 0).GetSeconds(), 0);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(23, 59, 59).GetSeconds(), 86399);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(14, 23, 47).GetSeconds(), 51827);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(0, 24, 12).GetSeconds(), 1452);
+ BOOST_CHECK_EQUAL(MakeTimeGmt(8, 0, 0).GetSeconds(), 28800);
+}
+
+BOOST_AUTO_TEST_CASE(MakeDate)
+{
+ using namespace common;
+
+ BOOST_CHECK_EQUAL(MakeDateGmt(1970, 1, 1).GetMilliseconds(), 0);
+ BOOST_CHECK_EQUAL(MakeDateGmt(2000, 12, 31).GetMilliseconds(), 978220800000);
+ BOOST_CHECK_EQUAL(MakeDateGmt(2017, 3, 20).GetMilliseconds(), 1489968000000);
+
+ BOOST_CHECK_EQUAL(MakeDateGmt(1970, 1, 1).GetSeconds(), 0);
+ BOOST_CHECK_EQUAL(MakeDateGmt(2000, 12, 31).GetSeconds(), 978220800);
+ BOOST_CHECK_EQUAL(MakeDateGmt(2017, 3, 20).GetSeconds(), 1489968000);
+}
+
+BOOST_AUTO_TEST_CASE(MakeTimestamp)
+{
+ using namespace common;
+
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(1970, 1, 1, 0, 0, 0, 0).GetMilliseconds(), 0);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2000, 12, 31, 23, 59, 59, 999999999).GetMilliseconds(), 978307199999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2001, 9, 9, 1, 46, 39, 999999999).GetMilliseconds(), 999999999999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2017, 3, 20, 18, 43, 19, 170038645).GetMilliseconds(), 1490035399170);
+
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(1970, 1, 1, 0, 0, 0, 0).GetSeconds(), 0);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2000, 12, 31, 23, 59, 59, 999999999).GetSeconds(), 978307199);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2001, 9, 9, 1, 46, 39, 999999999).GetSeconds(), 999999999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2017, 3, 20, 18, 43, 19, 170038645).GetSeconds(), 1490035399);
+
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(1970, 1, 1, 0, 0, 0, 0).GetSecondFraction(), 0);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2000, 12, 31, 23, 59, 59, 999999999).GetSecondFraction(), 999999999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2001, 9, 9, 1, 46, 39, 999999999).GetSecondFraction(), 999999999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2017, 3, 20, 18, 43, 19, 170038645).GetSecondFraction(), 170038645);
+
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(1970, 1, 1, 0, 0, 0, 0).GetDate().GetMilliseconds(), 0);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2000, 12, 31, 23, 59, 59, 999999999).GetDate().GetMilliseconds(), 978307199999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2001, 9, 9, 1, 46, 39, 999999999).GetDate().GetMilliseconds(), 999999999999);
+ BOOST_CHECK_EQUAL(MakeTimestampGmt(2017, 3, 20, 18, 43, 19, 170038645).GetDate().GetMilliseconds(), 1490035399170);
+}
+
+BOOST_AUTO_TEST_CASE(CastDateToTm)
+{
+ CheckDate(2024, 8, 5);
+ CheckDate(1987, 1, 1);
+ CheckDate(1999, 2, 18);
+ CheckDate(1997, 12, 9);
+ CheckDate(2007, 12, 31);
+ CheckDate(2001, 6, 21);
+}
+
+BOOST_AUTO_TEST_CASE(CastTimestampToTm)
+{
+ CheckTimestamp(1970, 1, 1, 0, 0, 0, 0);
+ CheckTimestamp(2000, 12, 31, 23, 59, 59, 999999999);
+ CheckTimestamp(2001, 9, 9, 1, 46, 39, 999999999);
+ CheckTimestamp(2017, 3, 20, 18, 43, 19, 170038645);
+ CheckTimestamp(2007, 12, 31, 19, 24, 44, 894375963);
+ CheckTimestamp(2001, 6, 21, 13, 53, 2, 25346547);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
[2/2] ignite git commit: IGNITE-4690: CPP: Added ignite::Time type
Posted by is...@apache.org.
IGNITE-4690: CPP: Added ignite::Time type
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/02991d30
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/02991d30
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/02991d30
Branch: refs/heads/master
Commit: 02991d3066b73c1a006afb55b4138e33a2e99ed3
Parents: 19ba8f4
Author: Igor Sapego <is...@gridgain.com>
Authored: Tue Mar 21 14:53:29 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Tue Mar 21 14:53:29 2017 +0300
----------------------------------------------------------------------
.../include/ignite/binary/binary_raw_reader.h | 19 +
.../include/ignite/binary/binary_raw_writer.h | 15 +
.../include/ignite/binary/binary_reader.h | 21 +
.../include/ignite/binary/binary_writer.h | 17 +
.../include/ignite/impl/binary/binary_common.h | 6 +
.../ignite/impl/binary/binary_reader_impl.h | 128 ++-
.../include/ignite/impl/binary/binary_utils.h | 25 +-
.../ignite/impl/binary/binary_writer_impl.h | 46 +-
.../cpp/binary/src/binary/binary_raw_reader.cpp | 10 +
.../cpp/binary/src/binary/binary_raw_writer.cpp | 10 +
.../cpp/binary/src/binary/binary_reader.cpp | 12 +-
.../cpp/binary/src/binary/binary_writer.cpp | 10 +
.../src/impl/binary/binary_reader_impl.cpp | 177 +++-
.../cpp/binary/src/impl/binary/binary_utils.cpp | 12 +
.../src/impl/binary/binary_writer_impl.cpp | 105 ++-
modules/platforms/cpp/common/Makefile.am | 3 +-
.../platforms/cpp/common/include/Makefile.am | 1 +
.../cpp/common/include/ignite/common/utils.h | 53 +-
.../platforms/cpp/common/include/ignite/time.h | 138 +++
.../cpp/common/project/vs/common.vcxproj | 2 +
.../common/project/vs/common.vcxproj.filters | 6 +
.../platforms/cpp/common/src/common/utils.cpp | 30 +
modules/platforms/cpp/common/src/time.cpp | 83 ++
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../cpp/core-test/config/cache-query.xml | 23 +
.../include/ignite/binary_test_utils.h | 53 ++
.../cpp/core-test/include/ignite/test_type.h | 11 +-
.../cpp/core-test/project/vs/core-test.vcxproj | 1 +
.../project/vs/core-test.vcxproj.filters | 3 +
.../cpp/core-test/src/binary_object_test.cpp | 110 +--
.../src/binary_reader_writer_raw_test.cpp | 712 +++------------
.../core-test/src/binary_reader_writer_test.cpp | 913 +++----------------
.../cpp/core-test/src/binary_session_test.cpp | 18 +
.../cpp/core-test/src/cache_query_test.cpp | 65 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 12 +
.../cpp/core-test/src/date_time_test.cpp | 265 ++++++
36 files changed, 1491 insertions(+), 1625 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
index d15848b..d110078 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
@@ -275,6 +275,25 @@ namespace ignite
int32_t ReadTimestampArray(Timestamp* res, int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @return Result.
+ */
+ Time ReadTime();
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(Time* res, int32_t len);
+
+ /**
* Read string.
*
* @param res Array to store data to.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
index c960406..88a8014 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
@@ -230,6 +230,21 @@ namespace ignite
void WriteTimestampArray(const Timestamp* val, int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteTime(const Time& val);
+
+ /**
+ * Write array of Time. Maps to "Time[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param val Null-terminated character array.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
index e4eb690..e07ec14 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
@@ -296,6 +296,27 @@ namespace ignite
int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Time ReadTime(const char* fieldName);
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len);
+
+ /**
* Read string.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
index 1923694..e3962cf 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
@@ -248,6 +248,23 @@ namespace ignite
void WriteTimestampArray(const char* fieldName, const Timestamp* val, const int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteTime(const char* fieldName, const Time& val);
+
+ /**
+ * Write array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const char* fieldName, const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
index aa15cc5..a4275c7 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
@@ -164,6 +164,12 @@ namespace ignite
/** Type: timestamp array. */
const int8_t IGNITE_TYPE_ARRAY_TIMESTAMP = 34;
+ /** Type: time. */
+ const int8_t IGNITE_TYPE_TIME = 36;
+
+ /** Type: time array. */
+ const int8_t IGNITE_TYPE_ARRAY_TIME = 37;
+
/** Read/write single object. */
const int32_t IGNITE_BINARY_MODE_SINGLE = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 814651d..242bb1e 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -33,6 +33,7 @@
#include "ignite/guid.h"
#include "ignite/date.h"
#include "ignite/timestamp.h"
+#include "ignite/time.h"
namespace ignite
{
@@ -513,6 +514,46 @@ namespace ignite
int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @return Result.
+ */
+ Time ReadTime();
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(Time* res, int32_t len);
+
+ /**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Time ReadTime(const char* fieldName);
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len);
+
+ /**
* Read string.
*
* @param len Expected length of string.
@@ -1065,16 +1106,26 @@ namespace ignite
);
/**
+ * Internal routine to read Time array.
+ *
+ * @param stream Stream.
+ * @param res Resulting array.
+ * @param len Length.
+ */
+ static void ReadTimeArrayInternal(
+ interop::InteropInputStream* stream,
+ Time* res,
+ const int32_t len
+ );
+
+ /**
* Read single value in raw mode.
*
- * @param stream Stream.
* @param func Function to be invoked on stream.
* @return Result.
*/
template<typename T>
- T ReadRaw(
- T(*func) (interop::InteropInputStream*)
- )
+ T ReadRaw(T(*func)(interop::InteropInputStream*))
{
{
CheckRawMode(true);
@@ -1347,43 +1398,7 @@ namespace ignite
* @param func Function to be applied to the stream.
*/
template<typename T>
- T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*))
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == expHdr)
- return func(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return GetNull<T>();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
- }
- }
-
- /**
- * Read value.
- *
- * @param expHdr Expected header.
- * @param func Function to be applied to the stream.
- * @param dflt Default value.
- */
- template<typename T>
- T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*), T dflt)
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == expHdr)
- return func(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return dflt;
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
- }
- }
+ T ReadTopObject0(const int8_t expHdr, T (*func)(ignite::impl::interop::InteropInputStream*));
};
template<>
@@ -1420,35 +1435,10 @@ namespace ignite
Timestamp IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Timestamp>();
template<>
- inline std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>()
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_STRING)
- {
- int32_t realLen = stream->ReadInt32();
-
- std::string res;
+ Time IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Time>();
- if (realLen > 0)
- {
- res.resize(realLen, 0);
-
- stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
- }
-
- return res;
- }
- else if (typeId == IGNITE_HDR_NULL)
- return std::string();
- else
- {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos,
- "expected", static_cast<int>(IGNITE_TYPE_STRING), "actual", static_cast<int>(typeId))
- }
- }
+ template<>
+ std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
index b541483..6cd90b0 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
@@ -25,6 +25,7 @@
#include "ignite/guid.h"
#include "ignite/date.h"
#include "ignite/timestamp.h"
+#include "ignite/time.h"
#include "ignite/binary/binary_type.h"
@@ -424,7 +425,7 @@ namespace ignite
* Utility method to read Timestamp from stream.
*
* @param stream Stream.
- * @param res Value.
+ * @return Value.
*/
static Timestamp ReadTimestamp(interop::InteropInputStream* stream);
@@ -437,6 +438,22 @@ namespace ignite
static void WriteTimestamp(interop::InteropOutputStream* stream, const Timestamp val);
/**
+ * Utility method to read Time from stream.
+ *
+ * @param stream Stream.
+ * @return Value.
+ */
+ static Time ReadTime(interop::InteropInputStream* stream);
+
+ /**
+ * Utility method to write Timestamp to stream.
+ *
+ * @param stream Stream.
+ * @param val Value.
+ */
+ static void WriteTime(interop::InteropOutputStream* stream, const Time val);
+
+ /**
* Utility method to write string to stream.
*
* @param stream Stream.
@@ -526,6 +543,12 @@ namespace ignite
}
template<>
+ inline Time BinaryUtils::GetDefaultValue<Time>()
+ {
+ return Time();
+ }
+
+ template<>
inline std::string BinaryUtils::GetDefaultValue<std::string>()
{
return std::string();
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
index fc38837..ea5f81f 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
@@ -424,6 +424,38 @@ namespace ignite
void WriteTimestampArray(const char* fieldName, const Timestamp* val, const int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteTime(const Time& val);
+
+ /**
+ * Write array of Time. Maps to "Time[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const Time* val, const int32_t len);
+
+ /**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteTime(const char* fieldName, const Time& val);
+
+ /**
+ * Write array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const char* fieldName, const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param val String.
@@ -914,7 +946,7 @@ namespace ignite
/**
* Check whether session ID matches.
*
- * @param ses Expected session ID.
+ * @param expSes Expected session ID.
*/
void CheckSession(int32_t expSes) const;
@@ -975,16 +1007,10 @@ namespace ignite
void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Timestamp& obj);
template<>
- inline void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj)
- {
- const char* obj0 = obj.c_str();
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Time& obj);
- int32_t len = static_cast<int32_t>(obj.size());
-
- stream->WriteInt8(IGNITE_TYPE_STRING);
-
- BinaryUtils::WriteString(stream, obj0, len);
- }
+ template<>
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp b/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
index e472588..9c1d6d9 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
@@ -139,6 +139,16 @@ namespace ignite
return impl->ReadTimestampArray(res, len);
}
+ Time BinaryRawReader::ReadTime()
+ {
+ return impl->ReadTime();
+ }
+
+ int32_t BinaryRawReader::ReadTimeArray(Time* res, int32_t len)
+ {
+ return impl->ReadTimeArray(res, len);
+ }
+
int32_t BinaryRawReader::ReadString(char* res, const int32_t len)
{
return impl->ReadString(res, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp b/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
index a83c74b..f2e94a5 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
@@ -139,6 +139,16 @@ namespace ignite
impl->WriteTimestampArray(val, len);
}
+ void BinaryRawWriter::WriteTime(const Time& val)
+ {
+ impl->WriteTime(val);
+ }
+
+ void BinaryRawWriter::WriteTimeArray(const Time* val, const int32_t len)
+ {
+ impl->WriteTimeArray(val, len);
+ }
+
void BinaryRawWriter::WriteString(const char* val)
{
if (val)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_reader.cpp b/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
index 814db83..f9fa72e 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
@@ -138,7 +138,17 @@ namespace ignite
{
return impl->ReadTimestampArray(fieldName, res, len);
}
-
+
+ Time BinaryReader::ReadTime(const char* fieldName)
+ {
+ return impl->ReadTime(fieldName);
+ }
+
+ int32_t BinaryReader::ReadTimeArray(const char* fieldName, Time* res, const int32_t len)
+ {
+ return impl->ReadTimeArray(fieldName, res, len);
+ }
+
int32_t BinaryReader::ReadString(const char* fieldName, char* res, int32_t len)
{
return impl->ReadString(fieldName, res, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_writer.cpp b/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
index efbc0ce..6c549bb 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
@@ -139,6 +139,16 @@ namespace ignite
impl->WriteTimestampArray(fieldName, val, len);
}
+ void BinaryWriter::WriteTime(const char* fieldName, const Time& val)
+ {
+ impl->WriteTime(fieldName, val);
+ }
+
+ void BinaryWriter::WriteTimeArray(const char* fieldName, const Time* val, const int32_t len)
+ {
+ impl->WriteTimeArray(fieldName, val, len);
+ }
+
void BinaryWriter::WriteString(const char* fieldName, const char* val)
{
if (val)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
index c128df6..1c4104b 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
@@ -378,7 +378,63 @@ namespace ignite
void BinaryReaderImpl::ReadTimestampArrayInternal(interop::InteropInputStream* stream, Timestamp* res, const int32_t len)
{
for (int i = 0; i < len; i++)
- *(res + i) = ReadNullable<Timestamp>(stream, BinaryUtils::ReadTimestamp, IGNITE_TYPE_TIMESTAMP);
+ res[i] = ReadNullable<Timestamp>(stream, BinaryUtils::ReadTimestamp, IGNITE_TYPE_TIMESTAMP);
+ }
+
+ Time BinaryReaderImpl::ReadTime()
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadNullable(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
+ }
+
+ int32_t BinaryReaderImpl::ReadTimeArray(Time * res, int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadArrayInternal<Time>(res, len, stream, ReadTimeArrayInternal, IGNITE_TYPE_ARRAY_TIME);
+ }
+
+ Time BinaryReaderImpl::ReadTime(const char * fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return Time();
+
+ stream->Position(fieldPos);
+
+ return ReadNullable(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
+ }
+
+ int32_t BinaryReaderImpl::ReadTimeArray(const char * fieldName, Time * res, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t realLen = ReadArrayInternal<Time>(res, len, stream, ReadTimeArrayInternal, IGNITE_TYPE_ARRAY_TIME);
+
+ return realLen;
+ }
+
+ void BinaryReaderImpl::ReadTimeArrayInternal(interop::InteropInputStream* stream, Time* res, const int32_t len)
+ {
+ for (int i = 0; i < len; i++)
+ res[i] = ReadNullable<Time>(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
}
int32_t BinaryReaderImpl::ReadString(char* res, const int32_t len)
@@ -692,73 +748,55 @@ namespace ignite
template <>
int8_t BinaryReaderImpl::ReadTopObject<int8_t>()
{
- return ReadTopObject0(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8,
- BinaryUtils::GetDefaultValue<int8_t>());
+ return ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
}
template <>
bool BinaryReaderImpl::ReadTopObject<bool>()
{
- return ReadTopObject0(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool,
- BinaryUtils::GetDefaultValue<bool>());
+ return ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
}
template <>
int16_t BinaryReaderImpl::ReadTopObject<int16_t>()
{
- return ReadTopObject0(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16,
- BinaryUtils::GetDefaultValue<int16_t>());
+ return ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
}
template <>
uint16_t BinaryReaderImpl::ReadTopObject<uint16_t>()
{
- return ReadTopObject0(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16,
- BinaryUtils::GetDefaultValue<uint16_t>());
+ return ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
}
template <>
int32_t BinaryReaderImpl::ReadTopObject<int32_t>()
{
- return ReadTopObject0(IGNITE_TYPE_INT, BinaryUtils::ReadInt32,
- BinaryUtils::GetDefaultValue<int32_t>());
+ return ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
}
template <>
int64_t BinaryReaderImpl::ReadTopObject<int64_t>()
{
- return ReadTopObject0(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64,
- BinaryUtils::GetDefaultValue<int64_t>());
+ return ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
}
template <>
float BinaryReaderImpl::ReadTopObject<float>()
{
- return ReadTopObject0(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat,
- BinaryUtils::GetDefaultValue<float>());
+ return ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
}
template <>
double BinaryReaderImpl::ReadTopObject<double>()
{
- return ReadTopObject0(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble,
- BinaryUtils::GetDefaultValue<double>());
+ return ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
}
template <>
Guid BinaryReaderImpl::ReadTopObject<Guid>()
{
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_UUID)
- return BinaryUtils::ReadGuid(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return BinaryUtils::GetDefaultValue<Guid>();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_UUID, "actual", (int)typeId)
- }
+ return ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
}
template <>
@@ -775,23 +813,69 @@ namespace ignite
else {
int32_t pos = stream->Position() - 1;
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_DATE, "actual", (int)typeId)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_DATE, "actual", (int)typeId)
}
}
template <>
Timestamp BinaryReaderImpl::ReadTopObject<Timestamp>()
{
+ return ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
+ }
+
+ template<>
+ Time BinaryReaderImpl::ReadTopObject<Time>()
+ {
+ return ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
+ }
+
+ template<>
+ std::string BinaryReaderImpl::ReadTopObject<std::string>()
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_TYPE_STRING)
+ {
+ int32_t realLen = stream->ReadInt32();
+
+ std::string res;
+
+ if (realLen > 0)
+ {
+ res.resize(realLen, 0);
+
+ stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
+ }
+
+ return res;
+ }
+ else if (typeId == IGNITE_HDR_NULL)
+ return std::string();
+ else
+ {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos,
+ "expected", static_cast<int>(IGNITE_TYPE_STRING), "actual", static_cast<int>(typeId))
+ }
+ }
+
+ template <typename T>
+ T BinaryReaderImpl::ReadTopObject0(const int8_t expHdr, T(*func)(ignite::impl::interop::InteropInputStream*))
+ {
int8_t typeId = stream->ReadInt8();
- if (typeId == IGNITE_TYPE_TIMESTAMP)
- return BinaryUtils::ReadTimestamp(stream);
+ if (typeId == expHdr)
+ return func(stream);
else if (typeId == IGNITE_HDR_NULL)
- return BinaryUtils::GetDefaultValue<Timestamp>();
- else {
+ return BinaryUtils::GetDefaultValue<T>();
+ else
+ {
int32_t pos = stream->Position() - 1;
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_TIMESTAMP, "actual", (int)typeId)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
}
}
@@ -814,9 +898,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return static_cast<uint8_t>(stream->ReadInt8(schemaPos + 4)) + pos;
}
break;
@@ -828,9 +910,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return static_cast<uint16_t>(stream->ReadInt16(schemaPos + 4)) + pos;
}
break;
@@ -842,9 +922,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return stream->ReadInt32(schemaPos + 4) + pos;
}
break;
@@ -867,10 +945,12 @@ namespace ignite
void BinaryReaderImpl::CheckSingleMode(bool expected) const
{
if (expected && elemId != 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed when container is being read.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Operation cannot be performed when container is being read.");
}
else if (!expected && elemId == 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only when container is being read.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Operation can be performed only when container is being read.");
}
}
@@ -917,13 +997,16 @@ namespace ignite
void BinaryReaderImpl::CheckSession(int32_t expSes) const
{
if (elemId != expSes) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Containter read session has been finished or is not started yet.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Containter read session has been finished or is not started yet.");
}
}
void BinaryReaderImpl::ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr)
{
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)hdr)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected",
+ static_cast<int>(expHdr), "actual", static_cast<int>(hdr))
}
void BinaryReaderImpl::ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
index 5fe8d83..a583128 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
@@ -328,6 +328,18 @@ namespace ignite
stream->WriteInt32(val.GetSecondFraction() % 1000000);
}
+ Time BinaryUtils::ReadTime(interop::InteropInputStream* stream)
+ {
+ int64_t ms = stream->ReadInt64();
+
+ return Time(ms);
+ }
+
+ void BinaryUtils::WriteTime(interop::InteropOutputStream* stream, const Time val)
+ {
+ stream->WriteInt64(val.GetMilliseconds());
+ }
+
void BinaryUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
{
stream->WriteInt32(len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
index b8f95b3..15e1ab9 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
@@ -227,10 +227,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- Guid elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_UUID);
- BinaryUtils::WriteGuid(stream, elem);
+ BinaryUtils::WriteGuid(stream, val[i]);
}
}
else
@@ -262,11 +260,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- Guid elem = *(val + i);
-
- WriteTopObject(elem);
- }
+ WriteTopObject(val[i]);
}
else
{
@@ -296,10 +290,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- const Date& elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_DATE);
- BinaryUtils::WriteDate(stream, elem);
+ BinaryUtils::WriteDate(stream, val[i]);
}
}
else
@@ -331,11 +323,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- const Date& elem = *(val + i);
-
- WriteTopObject(elem);
- }
+ WriteTopObject(val[i]);
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
@@ -363,10 +351,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- const Timestamp& elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_TIMESTAMP);
- BinaryUtils::WriteTimestamp(stream, elem);
+ BinaryUtils::WriteTimestamp(stream, val[i]);
}
}
else
@@ -398,16 +384,73 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- const Timestamp& elem = *(val + i);
+ WriteTopObject(val[i]);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ void BinaryWriterImpl::WriteTime(const Time& val)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+
+ BinaryUtils::WriteTime(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteTimeArray(const Time* val, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_TIME);
+ stream->WriteInt32(len);
- WriteTopObject(elem);
+ for (int i = 0; i < len; i++)
+ {
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+ BinaryUtils::WriteTime(stream, val[i]);
}
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
}
+ void BinaryWriterImpl::WriteTime(const char* fieldName, const Time& val)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_TIME);
+
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+
+ BinaryUtils::WriteTime(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteTimeArray(const char* fieldName, const Time* val, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_TIME);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_TIME);
+ stream->WriteInt32(len);
+
+ for (int i = 0; i < len; i++)
+ WriteTopObject(val[i]);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
void BinaryWriterImpl::WriteString(const char* val, const int32_t len)
{
CheckRawMode(true);
@@ -705,6 +748,24 @@ namespace ignite
WriteTopObject0<Timestamp>(obj, BinaryUtils::WriteTimestamp, IGNITE_TYPE_TIMESTAMP);
}
+ template <>
+ void BinaryWriterImpl::WriteTopObject<Time>(const Time& obj)
+ {
+ WriteTopObject0<Time>(obj, BinaryUtils::WriteTime, IGNITE_TYPE_TIME);
+ }
+
+ template<>
+ void BinaryWriterImpl::WriteTopObject(const std::string& obj)
+ {
+ const char* obj0 = obj.c_str();
+
+ int32_t len = static_cast<int32_t>(obj.size());
+
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ BinaryUtils::WriteString(stream, obj0, len);
+ }
+
void BinaryWriterImpl::PostWrite()
{
int32_t lenWithoutSchema = stream->Position() - start;
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/Makefile.am b/modules/platforms/cpp/common/Makefile.am
index c4f4827..8515d5b 100644
--- a/modules/platforms/cpp/common/Makefile.am
+++ b/modules/platforms/cpp/common/Makefile.am
@@ -53,7 +53,8 @@ libignite_common_la_SOURCES = \
src/date.cpp \
src/ignite_error.cpp \
src/guid.cpp \
- src/timestamp.cpp
+ src/timestamp.cpp \
+ src/time.cpp
clean-local:
$(RM) *.gcno *.gcda
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/Makefile.am b/modules/platforms/cpp/common/include/Makefile.am
index 7f7ab83..cba68e9 100644
--- a/modules/platforms/cpp/common/include/Makefile.am
+++ b/modules/platforms/cpp/common/include/Makefile.am
@@ -32,6 +32,7 @@ nobase_include_HEADERS = \
ignite/guid.h \
ignite/ignite_error.h \
ignite/timestamp.h \
+ ignite/time.h \
ignite/reference.h
uninstall-hook:
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index bf1f39b..32d250f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -29,6 +29,7 @@
#include <ignite/date.h>
#include <ignite/timestamp.h>
+#include "ignite/time.h"
#ifdef IGNITE_FRIEND
# define IGNITE_FRIEND_EXPORT IGNITE_EXPORT
@@ -217,7 +218,7 @@ namespace ignite
}
/**
- * Convert standard C type time_t to Date struct tm.
+ * Convert standard C type time_t to Date.
*
* @param ctime Standard C type time_t.
* @return Corresponding value of Date.
@@ -228,6 +229,17 @@ namespace ignite
}
/**
+ * Convert standard C type time_t to Time.
+ *
+ * @param ctime Standard C type time_t.
+ * @return Corresponding value of Time.
+ */
+ inline Time CTimeToTime(time_t ctime)
+ {
+ return Time(ctime * 1000);
+ }
+
+ /**
* Convert standard C type time_t to Timestamp type.
*
* @param ctime Standard C type time_t.
@@ -253,6 +265,19 @@ namespace ignite
}
/**
+ * Convert standard C type struct tm to Time type.
+ *
+ * @param ctime Standard C type struct tm.
+ * @return Corresponding value of Time.
+ */
+ inline Time CTmToTime(const tm& ctime)
+ {
+ time_t time = common::IgniteTimeGm(ctime);
+
+ return CTimeToTime(time);
+ }
+
+ /**
* Convert standard C type struct tm to Timestamp type.
*
* @param ctime Standard C type struct tm.
@@ -299,7 +324,31 @@ namespace ignite
int day = 1, int hour = 0, int min = 0, int sec = 0);
/**
- * Make Date in human understandable way.
+ * Make Time in human understandable way.
+ *
+ * Created Time uses GMT timezone.
+ *
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @return Time.
+ */
+ Time MakeTimeGmt(int hour = 0, int min = 0, int sec = 0);
+
+ /**
+ * Make Time in human understandable way.
+ *
+ * Created Time uses Local timezone.
+ *
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @return Time.
+ */
+ Time MakeTimeLocal(int hour = 0, int min = 0, int sec = 0);
+
+ /**
+ * Make Timestamp in human understandable way.
*
* Created Timestamp uses GMT timezone.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/ignite/time.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/time.h b/modules/platforms/cpp/common/include/ignite/time.h
new file mode 100644
index 0000000..b922c6a
--- /dev/null
+++ b/modules/platforms/cpp/common/include/ignite/time.h
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file
+ * Declares ignite::Time class.
+ */
+
+#ifndef _IGNITE_TIME
+#define _IGNITE_TIME
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+ /**
+ * %Time type.
+ */
+ class IGNITE_IMPORT_EXPORT Time
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Time();
+
+ /**
+ * Copy constructor.
+ *
+ * @param another Another instance.
+ */
+ Time(const Time& another);
+
+ /**
+ * Constructor.
+ *
+ * @param ms Time in milliseconds since 00:00:00 UTC.
+ */
+ Time(int64_t ms);
+
+ /**
+ * Copy operator.
+ *
+ * @param another Another instance.
+ * @return This.
+ */
+ Time& operator=(const Time& another);
+
+ /**
+ * Returns number of milliseconds since 00:00:00 UTC.
+ *
+ * @return Number of milliseconds since 00:00:00 UTC.
+ */
+ int64_t GetMilliseconds() const;
+
+ /**
+ * Returns number of seconds since 00:00:00 UTC.
+ *
+ * @return Number of seconds since 00:00:00 UTC.
+ */
+ int64_t GetSeconds() const;
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator==(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if not equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator!=(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator<(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less or equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator<=(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator>(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter or equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator>=(const Time& val1, const Time& val2);
+ private:
+ /** Time in milliseconds since 00:00:00 UTC. */
+ int64_t milliseconds;
+ };
+}
+
+#endif //_IGNITE_TIME
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index 45ac15e..3062112 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -179,6 +179,7 @@
<ClInclude Include="..\..\include\ignite\guid.h" />
<ClInclude Include="..\..\include\ignite\ignite_error.h" />
<ClInclude Include="..\..\include\ignite\reference.h" />
+ <ClInclude Include="..\..\include\ignite\time.h" />
<ClInclude Include="..\..\include\ignite\timestamp.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\common.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\concurrent_os.h" />
@@ -196,6 +197,7 @@
<ClCompile Include="..\..\src\date.cpp" />
<ClCompile Include="..\..\src\guid.cpp" />
<ClCompile Include="..\..\src\ignite_error.cpp" />
+ <ClCompile Include="..\..\src\time.cpp" />
<ClCompile Include="..\..\src\timestamp.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
index 1613d5d..ed709f7 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
@@ -64,6 +64,9 @@
<ClInclude Include="..\..\include\ignite\common\platform_utils.h">
<Filter>Code\common</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\time.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\date.cpp">
@@ -102,5 +105,8 @@
<ClCompile Include="..\..\src\common\utils.cpp">
<Filter>Code\common</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\time.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/common/utils.cpp b/modules/platforms/cpp/common/src/common/utils.cpp
index 2b425c1..786d0fb 100644
--- a/modules/platforms/cpp/common/src/common/utils.cpp
+++ b/modules/platforms/cpp/common/src/common/utils.cpp
@@ -119,6 +119,36 @@ namespace ignite
return CTimeToDate(localTime);
}
+ Time MakeTimeGmt(int hour, int min, int sec)
+ {
+ tm date = { 0 };
+
+ date.tm_year = 70;
+ date.tm_mon = 0;
+ date.tm_mday = 1;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ return CTmToTime(date);
+ }
+
+ Time MakeTimeLocal(int hour, int min, int sec)
+ {
+ tm date = { 0 };
+
+ date.tm_year = 70;
+ date.tm_mon = 0;
+ date.tm_mday = 1;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ time_t localTime = common::IgniteTimeLocal(date);
+
+ return CTimeToTime(localTime);
+ }
+
Timestamp MakeTimestampGmt(int year, int month, int day,
int hour, int min, int sec, long ns)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/src/time.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/time.cpp b/modules/platforms/cpp/common/src/time.cpp
new file mode 100644
index 0000000..a37a9c9
--- /dev/null
+++ b/modules/platforms/cpp/common/src/time.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+#include "ignite/time.h"
+
+namespace ignite
+{
+ Time::Time() : milliseconds(0)
+ {
+ // No-op.
+ }
+
+ Time::Time(const Time& another) : milliseconds(another.milliseconds)
+ {
+ // No-op.
+ }
+
+ Time::Time(int64_t ms) : milliseconds(ms)
+ {
+ // No-op.
+ }
+
+ Time& Time::operator=(const Time& another)
+ {
+ milliseconds = another.milliseconds;
+
+ return *this;
+ }
+
+ int64_t Time::GetMilliseconds() const
+ {
+ return milliseconds;
+ }
+
+ int64_t Time::GetSeconds() const
+ {
+ return milliseconds / 1000;
+ }
+
+ bool operator==(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds == val2.milliseconds;
+ }
+
+ bool operator!=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds != val2.milliseconds;
+ }
+
+ bool operator<(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds < val2.milliseconds;
+ }
+
+ bool operator<=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds <= val2.milliseconds;
+ }
+
+ bool operator>(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds > val2.milliseconds;
+ }
+
+ bool operator>=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds >= val2.milliseconds;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am
index 873db71..25dee58 100644
--- a/modules/platforms/cpp/core-test/Makefile.am
+++ b/modules/platforms/cpp/core-test/Makefile.am
@@ -73,6 +73,7 @@ ignite_tests_SOURCES = \
src/binary_reader_writer_raw_test.cpp \
src/binary_reader_writer_test.cpp \
src/binary_session_test.cpp \
+ src/date_time_test.cpp \
src/decimal_test.cpp \
src/dynamic_size_array_test.cpp \
src/fixed_size_array_test.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query.xml b/modules/platforms/cpp/core-test/config/cache-query.xml
index bb18f7c..036c464 100644
--- a/modules/platforms/cpp/core-test/config/cache-query.xml
+++ b/modules/platforms/cpp/core-test/config/cache-query.xml
@@ -99,6 +99,29 @@
</list>
</property>
</bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="TimeCache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+ <property name="partitions" value="256"/>
+ </bean>
+ </property>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Integer"/>
+ <property name="valueType" value="java.sql.Time"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
</list>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
index bcec9fe..7701253 100644
--- a/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
@@ -30,6 +30,11 @@ namespace ignite_test
{
namespace binary
{
+ inline bool IsBinaryError(const IgniteError& err)
+ {
+ return err.GetCode() == IgniteError::IGNITE_ERR_BINARY;
+ }
+
template<typename T>
inline void Write(BinaryRawWriter& writer, T val)
{
@@ -163,6 +168,18 @@ namespace ignite_test
}
template<>
+ inline void Write(BinaryRawWriter& writer, Time val)
+ {
+ writer.WriteTime(val);
+ }
+
+ template<>
+ inline Time Read(BinaryRawReader& reader)
+ {
+ return reader.ReadTime();
+ }
+
+ template<>
inline void Write(BinaryRawWriter& writer, Timestamp val)
{
writer.WriteTimestamp(val);
@@ -307,6 +324,18 @@ namespace ignite_test
}
template<>
+ inline void WriteArray(BinaryRawWriter& writer, Time* val, int32_t len)
+ {
+ writer.WriteTimeArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, Time* val, int32_t len)
+ {
+ return reader.ReadTimeArray(val, len);
+ }
+
+ template<>
inline void WriteArray(BinaryRawWriter& writer, Timestamp* val, int32_t len)
{
writer.WriteTimestampArray(val, len);
@@ -451,6 +480,18 @@ namespace ignite_test
}
template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, Time val)
+ {
+ writer.WriteTime(fieldName, val);
+ }
+
+ template<>
+ inline Time Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadTime(fieldName);
+ }
+
+ template<>
inline void Write(BinaryWriter& writer, const char* fieldName, Timestamp val)
{
writer.WriteTimestamp(fieldName, val);
@@ -595,6 +636,18 @@ namespace ignite_test
}
template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, Time* val, int32_t len)
+ {
+ writer.WriteTimeArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, Time* val, int32_t len)
+ {
+ return reader.ReadTimeArray(fieldName, val, len);
+ }
+
+ template<>
inline void WriteArray(BinaryWriter& writer, const char* fieldName, Timestamp* val, int32_t len)
{
writer.WriteTimestampArray(fieldName, val, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
index b399afe..7c7e6a2 100644
--- a/modules/platforms/cpp/core-test/include/ignite/test_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -37,6 +37,7 @@ namespace ignite
doubleField(0.0),
boolField(false),
dateField(),
+ timeField(),
timestampField()
{
// No-op.
@@ -45,7 +46,7 @@ namespace ignite
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) :
+ const Date& dateField, const Time& timeField, const Timestamp& timestampField) :
allNulls(false),
i8Field(i8Field),
i16Field(i16Field),
@@ -57,6 +58,7 @@ namespace ignite
boolField(boolField),
guidField(guidField),
dateField(dateField),
+ timeField(timeField),
timestampField(timestampField)
{
// No-op.
@@ -76,6 +78,7 @@ namespace ignite
one.boolField == two.boolField &&
one.guidField == two.guidField &&
one.dateField == two.dateField &&
+ one.timeField == two.timeField &&
one.timestampField == two.timestampField &&
one.i8ArrayField == two.i8ArrayField;
}
@@ -91,6 +94,7 @@ namespace ignite
bool boolField;
Guid guidField;
Date dateField;
+ Time timeField;
Timestamp timestampField;
std::vector<int8_t> i8ArrayField;
};
@@ -125,6 +129,7 @@ namespace ignite
writer.WriteBool("boolField", obj.boolField);
writer.WriteGuid("guidField", obj.guidField);
writer.WriteDate("dateField", obj.dateField);
+ writer.WriteTime("timeField", obj.timeField);
writer.WriteTimestamp("timestampField", obj.timestampField);
if (obj.i8ArrayField.empty())
{
@@ -147,6 +152,7 @@ namespace ignite
writer.WriteNull("boolField");
writer.WriteNull("guidField");
writer.WriteNull("dateField");
+ writer.WriteNull("timeField");
writer.WriteNull("timestampField");
writer.WriteNull("i8ArrayField");
}
@@ -164,11 +170,12 @@ namespace ignite
bool boolField = reader.ReadBool("boolField");
Guid guidField = reader.ReadGuid("guidField");
Date dateField = reader.ReadDate("dateField");
+ Time timeField = reader.ReadTime("timeField");
Timestamp timestampField = reader.ReadTimestamp("timestampField");
TestType result(i8Field, i16Field, i32Field, i64Field, strField,
floatField, doubleField, boolField, guidField, dateField,
- timestampField);
+ timeField, timestampField);
int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
if (len > 0)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index 4d252b9..f22e885 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -50,6 +50,7 @@
<ClCompile Include="..\..\src\cluster_test.cpp" />
<ClCompile Include="..\..\src\cache_invoke_test.cpp" />
<ClCompile Include="..\..\src\concurrent_test.cpp" />
+ <ClCompile Include="..\..\src\date_time_test.cpp" />
<ClCompile Include="..\..\src\decimal_test.cpp" />
<ClCompile Include="..\..\src\dynamic_size_array_test.cpp" />
<ClCompile Include="..\..\src\fixed_size_array_test.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index c318644..fb0be1b 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -79,6 +79,9 @@
<ClCompile Include="..\..\src\test_utils.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\date_time_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\cache_store_test.cpp">
<Filter>Code</Filter>
</ClCompile>
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/binary_object_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_object_test.cpp b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
index fb3725f..6378266 100644
--- a/modules/platforms/cpp/core-test/src/binary_object_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
@@ -112,119 +112,12 @@ void CheckData(const T& obj)
BOOST_AUTO_TEST_SUITE(BinaryObjectTestSuite)
-#ifdef CHECK_BINARY_OBJECT_WITH_PRIMITIVES
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt8)
-{
- CheckSimple<int8_t>(0);
- CheckSimple<int8_t>(INT8_MAX);
- CheckSimple<int8_t>(INT8_MIN);
- CheckSimple<int8_t>(42);
- CheckSimple<int8_t>(-12);
- CheckSimple<int8_t>(0x7D);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt16)
-{
- CheckSimple<int32_t>(0);
- CheckSimple<int32_t>(INT16_MAX);
- CheckSimple<int32_t>(INT16_MIN);
- CheckSimple<int32_t>(42);
- CheckSimple<int32_t>(12321);
- CheckSimple<int32_t>(0x7AB0);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt32)
-{
- CheckSimple<int32_t>(0);
- CheckSimple<int32_t>(INT32_MAX);
- CheckSimple<int32_t>(INT32_MIN);
- CheckSimple<int32_t>(42);
- CheckSimple<int32_t>(1337);
- CheckSimple<int32_t>(0xA2496BC9);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt64)
-{
- CheckSimple<int64_t>(0);
- CheckSimple<int64_t>(INT64_MAX);
- CheckSimple<int64_t>(INT64_MIN);
- CheckSimple<int64_t>(42);
- CheckSimple<int64_t>(13371337133713371337LL);
- CheckSimple<int64_t>(0xA928673F501CC09E);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveBool)
-{
- CheckSimple<bool>(true);
- CheckSimple<bool>(false);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveFloat)
-{
- CheckSimple<float>(0.0);
- CheckSimple<float>(1E38f);
- CheckSimple<float>(-1E38f);
- CheckSimple<float>(1E-38f);
- CheckSimple<float>(-1E-38f);
- CheckSimple<float>(42.0f);
- CheckSimple<float>(42.42f);
- CheckSimple<float>(1337.1337f);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveDouble)
-{
- CheckSimple<double>(0);
- CheckSimple<double>(1E127);
- CheckSimple<double>(-1E127);
- CheckSimple<double>(1E-127);
- CheckSimple<double>(-1E-127);
- CheckSimple<double>(42);
- CheckSimple<double>(42.42);
- CheckSimple<double>(1337.1337 * 1337.1337);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveString)
-{
- CheckSimple<std::string>("");
- CheckSimple<std::string>("Lorem ipsum");
- CheckSimple<std::string>("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
- "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
- "quis nostrud exercitation");
-
- CheckSimple<std::string>(std::string(1000, '.'));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveGuid)
-{
- CheckSimple<Guid>(Guid(0, 0));
- CheckSimple<Guid>(Guid(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF));
- CheckSimple<Guid>(Guid(0x4F9039DEF0FB8000, 0x905AE8A2D6FD49C1));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveDate)
-{
- CheckSimpleNP<Date>(Date(0));
- CheckSimpleNP<Date>(common::MakeDateGmt(1998, 12, 3, 18, 32, 01));
- CheckSimpleNP<Date>(common::MakeDateGmt(2017, 1, 18, 20, 50, 41));
- CheckSimpleNP<Date>(common::MakeDateLocal(1998, 12, 3, 18, 32, 01));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveTimestamp)
-{
- CheckSimpleNP<Timestamp>(Timestamp(0));
- CheckSimpleNP<Timestamp>(common::MakeTimestampGmt(1998, 12, 3, 18, 32, 01, 593846589));
- CheckSimpleNP<Timestamp>(common::MakeTimestampGmt(2017, 1, 18, 20, 50, 41, 920700532));
- CheckSimpleNP<Timestamp>(common::MakeTimestampLocal(1998, 12, 3, 18, 32, 01, 2385));
-}
-
-#endif //CHECK_BINARY_OBJECT_WITH_PRIMITIVES
-
BOOST_AUTO_TEST_CASE(UserTestType)
{
CheckSimpleNP(TestType());
CheckSimpleNP(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
common::MakeDateGmt(1987, 6, 5),
+ common::MakeTimeGmt(13, 32, 9),
common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
}
@@ -270,6 +163,7 @@ BOOST_AUTO_TEST_CASE(UserTestTypeGetData)
CheckData(TestType());
CheckData(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
common::MakeDateGmt(1987, 6, 5),
+ common::MakeTimeGmt(13, 32, 9),
common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
}