Skip to content

Commit

Permalink
Fixes bug: Test durations in Test Explorer are wrong for systems setu…
Browse files Browse the repository at this point in the history
…p with a decimal symbol that is not '.'
  • Loading branch information
JohnnyHendriks committed Sep 6, 2018
1 parent e8c7657 commit 682c59b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Changes are relative to v1.0.0

- Improve Additional info output with respect to section. Is now more like standard Catch2 output.

### Bug fixes

- Bug: Test durations in Test Explorer are wrong for systems setup with a decimal symbol that is not '.'. Fixed.

## Changes for v1.3.0

### Extended Features
Expand Down
10 changes: 9 additions & 1 deletion Libraries/Catch2Interface/Reporter/OverallResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
** Basic Info **/

using System;
using System.Globalization;
using System.Xml;

namespace Catch2Interface.Reporter
Expand All @@ -24,6 +25,13 @@ This class is intended to handle the xml "OverallResult" node in a Catch2 Xml re
*/
public class OverallResult
{
#region Fields

private static NumberStyles _style = NumberStyles.Float;
private static CultureInfo _culture = CultureInfo.CreateSpecificCulture("en-US");

#endregion // Fields

#region Properties

public TimeSpan Duration { get; private set; }
Expand All @@ -46,7 +54,7 @@ public OverallResult(XmlNode node)
}

double duration = 0.0;
if (double.TryParse(node.Attributes["durationInSeconds"]?.Value, out duration))
if (double.TryParse(node.Attributes["durationInSeconds"]?.Value, _style, _culture, out duration))
{
Duration = new TimeSpan((Int64)(duration * TimeSpan.TicksPerSecond)); ;
}
Expand Down
10 changes: 9 additions & 1 deletion Libraries/Catch2Interface/Reporter/OverallResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
** Basic Info **/

using System;
using System.Globalization;
using System.Xml;

namespace Catch2Interface.Reporter
Expand All @@ -24,6 +25,13 @@ This class is intended to handle the xml "OverallResults" node in a Catch2 Xml r
*/
public class OverallResults
{
#region Fields

private static NumberStyles _style = NumberStyles.Float;
private static CultureInfo _culture = CultureInfo.CreateSpecificCulture("en-US");

#endregion // Fields

#region Properties

public int Successes { get; set; } = 0;
Expand Down Expand Up @@ -63,7 +71,7 @@ public OverallResults(XmlNode node)
}

double duration = 0.0;
if (double.TryParse(node.Attributes["durationInSeconds"]?.Value, out duration))
if (double.TryParse(node.Attributes["durationInSeconds"]?.Value, _style, _culture, out duration))
{
Duration = new TimeSpan((Int64)(duration * TimeSpan.TicksPerSecond)); ;
}
Expand Down
2 changes: 1 addition & 1 deletion VSIX/VSTestAdapterCatch2/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="VSTestAdapterCatch2.73ba8471-3771-47bf-bd23-49a1ba09af89" Version="1.3.1" Language="en-US" Publisher="Johnny Hendriks" />
<Identity Id="VSTestAdapterCatch2.73ba8471-3771-47bf-bd23-49a1ba09af89" Version="1.3.2" Language="en-US" Publisher="Johnny Hendriks" />
<DisplayName>Test Adapter for Catch2</DisplayName>
<Description xml:space="preserve">Test Adapter for use with the Catch2 C++ unit test framework.</Description>
<MoreInfo>https://github.com/JohnnyHendriks/TestAdapter_Catch2</MoreInfo>
Expand Down

0 comments on commit 682c59b

Please sign in to comment.