Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed issue #58 - boolean converter returning true for no #87

Merged
merged 1 commit into from

2 participants

@elaforc

No description provided.

@JoshClose
Owner

Thanks!

@JoshClose JoshClose merged commit 931c02d into from
@JoshClose
Owner

Version 1.13 which contains this fix is on NuGet now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
12 src/CsvHelper.Tests/TypeConversion/BooleanConverterTests.cs
@@ -40,14 +40,14 @@ public void ConvertFromStringTest()
Assert.False( (bool)converter.ConvertFromString( "False" ) );
Assert.False( (bool)converter.ConvertFromString( "FALSE" ) );
Assert.False( (bool)converter.ConvertFromString( "0" ) );
- Assert.True( (bool)converter.ConvertFromString( "no" ) );
- Assert.True( (bool)converter.ConvertFromString( "NO" ) );
- Assert.True( (bool)converter.ConvertFromString( "n" ) );
- Assert.True( (bool)converter.ConvertFromString( "N" ) );
+ Assert.False( (bool)converter.ConvertFromString( "no" ) );
+ Assert.False( (bool)converter.ConvertFromString( "NO" ) );
+ Assert.False( (bool)converter.ConvertFromString( "n" ) );
+ Assert.False( (bool)converter.ConvertFromString( "N" ) );
Assert.False( (bool)converter.ConvertFromString( " false " ) );
Assert.False( (bool)converter.ConvertFromString( " 0 " ) );
- Assert.True( (bool)converter.ConvertFromString( " no " ) );
- Assert.True( (bool)converter.ConvertFromString( " n " ) );
+ Assert.False( (bool)converter.ConvertFromString( " no " ) );
+ Assert.False( (bool)converter.ConvertFromString( " n " ) );
Assert.Throws<NotSupportedException>( () => converter.ConvertFromString( null ) );
}
View
2  src/CsvHelper/TypeConversion/BooleanConverter.cs
@@ -44,7 +44,7 @@ public override object ConvertFromString( CultureInfo culture, string text )
if( culture.CompareInfo.Compare( "no", t, CompareOptions.IgnoreCase ) == 0 ||
culture.CompareInfo.Compare( "n", t, CompareOptions.IgnoreCase ) == 0 )
{
- return true;
+ return false;
}
return base.ConvertFromString( culture, text );
Something went wrong with that request. Please try again.