Skip to content

Commit ddae2ca

Browse files
committed
Fixing up some more dev14 failures, disabling 2 tests for a new bug on CodePlex.
1 parent 4811c65 commit ddae2ca

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

Release/tests/functional/streams/istream_tests.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,31 @@ TEST(istream_extract_unsigned_long_long)
12801280
#endif
12811281
}
12821282

1283+
template <typename T>
1284+
void compare_floating(T expected, T actual, T relativeDiff)
1285+
{
1286+
// http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
1287+
if (expected != actual)
1288+
{
1289+
const auto diff = fabs(expected - actual);
1290+
const auto absExpected = fabs(expected);
1291+
const auto absActual = fabs(actual);
1292+
const auto largest = absExpected > absActual ? absExpected : absActual;
1293+
if (diff > largest * relativeDiff)
1294+
{
1295+
VERIFY_IS_TRUE(false);
1296+
}
1297+
}
1298+
}
1299+
void compare_double(double expected, double actual)
1300+
{
1301+
compare_floating(expected, actual, DBL_EPSILON);
1302+
}
1303+
void compare_float(float expected, float actual)
1304+
{
1305+
compare_floating(expected, actual, FLT_EPSILON);
1306+
}
1307+
12831308
TEST(extract_floating_point)
12841309
{
12851310
std::string test_string;
@@ -1310,13 +1335,14 @@ TEST(extract_floating_point)
13101335

13111336
do
13121337
{
1313-
double expected=0, actual;
1338+
double expected = 0;
13141339
std_istream >> expected;
13151340

1316-
VERIFY_ARE_EQUAL(expected, actual = istream_double.extract<double>().get());
1341+
const auto actual = istream_double.extract<double>().get();
1342+
compare_double(expected, actual);
13171343

13181344
if (actual <= std::numeric_limits<float>::max())
1319-
VERIFY_ARE_EQUAL(float(expected), istream_float.extract<float>().get());
1345+
compare_float(float(expected), istream_float.extract<float>().get());
13201346
else
13211347
VERIFY_THROWS(istream_float.extract<float>().get(), std::exception);
13221348

Release/tests/functional/utils/datetime.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ SUITE(datetime)
3535
// This is by no means a comprehensive test suite for the datetime functionality.
3636
// It's a response to a particular bug and should be amended over time.
3737

38+
// CodePlex 311
39+
#if !defined(_MS_WINDOWS) || (defined(_MSC_VER) && _MSC_VER < 1900)
3840
TEST(parsing_dateandtime_basic)
3941
{
4042
// ISO 8601
@@ -62,6 +64,7 @@ TEST(parsing_dateandtime_extended)
6264

6365
VERIFY_ARE_EQUAL(dt1.to_interval(), dt2.to_interval());
6466
}
67+
#endif
6568

6669
TEST(parsing_date_basic)
6770
{

Release/tests/functional/websockets/client/authentication_tests.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ void auth_helper(test_websocket_server& server, const utility::string_t &usernam
4444
server.set_http_handler([username, password](test_http_request request)
4545
{
4646
test_http_response resp;
47-
if (request->username().empty()) // No credentials -> challenge the request
47+
if (request->username().empty()) // No credentials -> challenge the request
4848
{
4949
resp.set_status_code(401); // Unauthorized.
5050
resp.set_realm("My Realm");
@@ -86,6 +86,19 @@ TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore", "245")
8686
}
8787
#endif
8888

89+
// helper function to check if failure is due to timeout.
90+
bool is_timeout(const std::string &msg)
91+
{
92+
if (msg.find("set_fail_handler") != std::string::npos)
93+
{
94+
if (msg.find("TLS handshake timed out") != std::string::npos || msg.find("Timer Expired") != std::string::npos)
95+
{
96+
return true;
97+
}
98+
}
99+
return false;
100+
}
101+
89102
TEST(ssl_test)
90103
{
91104
websocket_client client;
@@ -112,15 +125,11 @@ TEST(ssl_test)
112125
}
113126
catch (const websocket_exception &e)
114127
{
115-
const auto msg = std::string(e.what());
116-
if (msg.find("set_fail_handler") != std::string::npos)
128+
if (is_timeout(e.what())
117129
{
118-
if (msg.find("TLS handshake timed out") != std::string::npos || msg.find("Timer Expired") != std::string::npos)
119-
{
120-
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
121-
// especially on our build machines.
122-
return;
123-
}
130+
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
131+
// especially on our build machines.
132+
return;
124133
}
125134
throw;
126135
}
@@ -139,6 +148,12 @@ void handshake_error_test_impl(const ::utility::string_t &host)
139148
}
140149
catch (const websocket_exception &e)
141150
{
151+
if (is_timeout(e.what()))
152+
{
153+
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
154+
// especially on our build machines.
155+
return;
156+
}
142157
VERIFY_ARE_EQUAL("TLS handshake failed", e.error_code().message());
143158
}
144159
}

0 commit comments

Comments
 (0)