-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue 47 with enumerating certain high value flag values (#48)
* Fix issue 47 with enumerating certain high value flag values * Target .NET 7 for test
- Loading branch information
1 parent
a35664d
commit 6ef93d0
Showing
5 changed files
with
49 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace EnumsNET.Tests.Issues | ||
{ | ||
[TestFixture] | ||
public class Issue47 | ||
{ | ||
[Test] | ||
public void AsString_SuccessfullyReturnsValue_WhenUsingLargeFlagEnumValue() | ||
{ | ||
Assert.AreEqual("Val1, Val30", (MyEnum.Val1 | MyEnum.Val30).AsString()); | ||
} | ||
|
||
#if SPAN | ||
[Test] | ||
public void TryFormat_SuccessfullyReturnsValue_WhenUsingLargeFlagEnumValue() | ||
{ | ||
var destination = new char[20]; | ||
Assert.True((MyEnum.Val1 | MyEnum.Val30).TryFormat(destination, out var charsWritten)); | ||
Assert.AreEqual(11, charsWritten); | ||
Assert.AreEqual("Val1, Val30", new string(destination[..charsWritten])); | ||
} | ||
#endif | ||
|
||
[Flags] | ||
public enum MyEnum | ||
{ | ||
Unknown = 0, | ||
Val1 = 1 << 0, | ||
Val30 = 1 << 30, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters