Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Fixes build on g++ 6.3.1 #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/odata/common/compat/SafeInt3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3247,6 +3247,7 @@ template < typename T, typename U > class DivisionHelper< T, U, DivisionState_Si
result = (T)((__int64)t/(__int64)u);
}
else // Corner case
{
if( t == IntTraits< T >::minInt && u == (unsigned __int64)IntTraits< T >::minInt )
{
// Min int divided by it's own magnitude is -1
Expand All @@ -3256,7 +3257,8 @@ template < typename T, typename U > class DivisionHelper< T, U, DivisionState_Si
{
result = 0;
}
return SafeIntNoError;
}
return SafeIntNoError;
}

template < typename E >
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/core_test/odata_json_reader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ TEST(json_primitive_double)
auto primitive_type = std::dynamic_pointer_cast<edm_primitive_type>(primitive_value->get_value_type());
VERIFY_ARE_EQUAL(primitive_type->get_primitive_kind(), edm_primitive_type_kind_t::Double);
VERIFY_ARE_EQUAL(primitive_type->get_type_kind(), edm_type_kind_t::Primitive);
VERIFY_IS_TRUE(abs(primitive_value->as<double>() - 123.3434) < 0.000001);
VERIFY_IS_TRUE(std::abs(primitive_value->as<double>() - 123.3434) < 0.000001);
}

TEST(json_primitive_float)
Expand All @@ -572,7 +572,7 @@ TEST(json_primitive_float)
auto primitive_type = std::dynamic_pointer_cast<edm_primitive_type>(primitive_value->get_value_type());
VERIFY_ARE_EQUAL(primitive_type->get_primitive_kind(), edm_primitive_type_kind_t::Single);
VERIFY_ARE_EQUAL(primitive_type->get_type_kind(), edm_type_kind_t::Primitive);
VERIFY_IS_TRUE(abs(primitive_value->as<float>() - -123.4) < 0.00001);
VERIFY_IS_TRUE(std::abs(primitive_value->as<float>() - -123.4) < 0.00001);
}

TEST(json_primitive_duration)
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/core_test/odata_value_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST(primitive_value)
VERIFY_ARE_EQUAL(float_v->get_value_type()->get_type_kind(), edm_type_kind_t::Primitive);
primitive_type = std::dynamic_pointer_cast<edm_primitive_type>(float_v->get_value_type());
VERIFY_ARE_EQUAL(primitive_type->get_primitive_kind(), edm_primitive_type_kind_t::Single);
VERIFY_IS_TRUE(abs(float_v->as<float>() - -121.2312) < 0.00001);
VERIFY_IS_TRUE(std::abs(float_v->as<float>() - -121.2312) < 0.00001);

//string
auto str_v = odata_primitive_value::make_primitive_value(U("test string"));
Expand Down Expand Up @@ -242,7 +242,7 @@ TEST(structured_value)
VERIFY_ARE_EQUAL(str, U("string_t input"));
b_get = structurd_value->try_get(U("double"), db);
VERIFY_ARE_EQUAL(b_get, true);
double as = abs(db - -32342212.23424);
double as = std::abs(db - -32342212.23424);
VERIFY_ARE_EQUAL(as < 0.000001, true);
}

Expand Down Expand Up @@ -370,11 +370,11 @@ TEST(primitive_collection_value)
collection_value->add_collection_value(p_value_3);

p_value_1 = std::dynamic_pointer_cast<odata_primitive_value>(collection_value->get_collection_values()[0]);
VERIFY_IS_TRUE(abs(p_value_1->as<double>() - -12123.2312) < 0.000001);
VERIFY_IS_TRUE(std::abs(p_value_1->as<double>() - -12123.2312) < 0.000001);
p_value_2 = std::dynamic_pointer_cast<odata_primitive_value>(collection_value->get_collection_values()[1]);
VERIFY_IS_TRUE(abs(p_value_2->as<double>() - -123123213) < 0.000001);
VERIFY_IS_TRUE(std::abs(p_value_2->as<double>() - -123123213) < 0.000001);
p_value_3 = std::dynamic_pointer_cast<odata_primitive_value>(collection_value->get_collection_values()[2]);
VERIFY_IS_TRUE(abs(p_value_3->as<double>() - -121.2312) < 0.000001);
VERIFY_IS_TRUE(std::abs(p_value_3->as<double>() - -121.2312) < 0.000001);
}

TEST(complex_collection_value)
Expand Down