Browse files

Fixed issue #58 - boolean converter returning true for no

  • Loading branch information...
1 parent 47313ad commit b8101526934d7ee7a5aae93f41e58ae6b1da194e Eric LaForce committed Dec 8, 2012
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 );

0 comments on commit b810152

Please sign in to comment.