|
8 | 8 |
|
9 | 9 | using namespace std;
|
10 | 10 |
|
11 |
| -#define TEST_EXPLICIT_IMBUE |
12 |
| - |
13 |
| -#if defined(_MSC_VER) |
14 |
| -#if defined(__clang__) |
| 11 | +#if defined(_MSC_VER) && defined(__clang__) |
15 | 12 | #pragma clang diagnostic ignored "-Wstring-plus-int"
|
16 | 13 | #endif
|
17 | 14 |
|
18 |
| -#if _MSC_VER <= 1900 |
19 |
| -#undef TEST_EXPLICIT_IMBUE |
20 |
| -#endif |
21 |
| -#endif |
22 |
| - |
23 | 15 |
|
24 | 16 | /****************************************************************************
|
25 | 17 | *
|
@@ -2405,6 +2397,17 @@ istream & operator>>(istream & is, EnumAB & val) {
|
2405 | 2397 | void unitsTests() {
|
2406 | 2398 | int line = 0;
|
2407 | 2399 | CliTest cli;
|
| 2400 | +#if defined(_MSC_VER) && _MSC_VER <= 1900 |
| 2401 | + // Don't directly construct locale("en_US") in MSVC 2015 because of a bug |
| 2402 | + // in the locale implementation that may cause it to hang in debug builds. |
| 2403 | + setlocale(LC_ALL, "en_US"); |
| 2404 | + EXPECT(true); |
| 2405 | + locale loc(""); |
| 2406 | + EXPECT(true); |
| 2407 | +#else |
| 2408 | + locale loc("en_US"); |
| 2409 | + EXPECT(true); |
| 2410 | +#endif |
2408 | 2411 |
|
2409 | 2412 | // si units
|
2410 | 2413 | {
|
@@ -2482,15 +2485,6 @@ Units symbol 'k' not recognized.
|
2482 | 2485 | EXPECT(*sv == "1000000");
|
2483 | 2486 |
|
2484 | 2487 | auto & si = cli.opt<int>("i").siUnits();
|
2485 |
| -#ifdef TEST_EXPLICIT_IMBUE |
2486 |
| - locale loc("en_US"); |
2487 |
| - EXPECT(true); |
2488 |
| -#else |
2489 |
| - setlocale(LC_ALL, "en_US"); |
2490 |
| - EXPECT(true); |
2491 |
| - locale loc(""); |
2492 |
| - EXPECT(true); |
2493 |
| -#endif |
2494 | 2488 | si.imbue(loc);
|
2495 | 2489 | EXPECT_PARSE(cli, "-i2G");
|
2496 | 2490 | EXPECT(*si == 2'000'000'000);
|
@@ -2529,12 +2523,6 @@ Usage: test [OPTIONS] [V...]
|
2529 | 2523 | {
|
2530 | 2524 | cli = {};
|
2531 | 2525 | auto & sht = cli.opt<uint16_t>("s").timeUnits();
|
2532 |
| -#ifdef TEST_EXPLICIT_IMBUE |
2533 |
| - locale loc("en_US"); |
2534 |
| -#else |
2535 |
| - setlocale(LC_ALL, "en_US"); |
2536 |
| - locale loc(""); |
2537 |
| -#endif |
2538 | 2526 | sht.imbue(loc);
|
2539 | 2527 | EXPECT_HELP(cli, "", 1 + R"(
|
2540 | 2528 | Usage: test [OPTIONS]
|
@@ -2573,7 +2561,7 @@ Must be between '0' and '65,535'.
|
2573 | 2561 | EXPECT_PARSE(cli, "-v1ms -v1us -v1ns");
|
2574 | 2562 | EXPECT(dbls[0] == 1e-3);
|
2575 | 2563 | #if defined(_MSC_VER) && _MSC_VER != 1938
|
2576 |
| - // Exclude these from MSVC 2022 17.8 because of bug in it's stream |
| 2564 | + // Exclude these from MSVC 2022 17.8 because of a bug in it's stream |
2577 | 2565 | // library.
|
2578 | 2566 | EXPECT(dbls[1] == 1e-6);
|
2579 | 2567 | EXPECT(dbls[2] == 1e-9);
|
|
0 commit comments