-
-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #753 from SixLabors/dl/fix-750
Added missing length check that caused an ArgumentNullException (#750)
- Loading branch information
Showing
7 changed files
with
43 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Six Labors and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace SixLabors.ImageSharp.Tests.Common | ||
{ | ||
public class EncoderExtensionsTests | ||
{ | ||
[Fact] | ||
public void GetString_EmptyBuffer_ReturnsEmptyString() | ||
{ | ||
var buffer = new ReadOnlySpan<byte>(); | ||
|
||
string result = Encoding.UTF8.GetString(buffer); | ||
|
||
Assert.Equal(string.Empty, result); | ||
} | ||
|
||
[Fact] | ||
public void GetString_Buffer_ReturnsString() | ||
{ | ||
var buffer = new ReadOnlySpan<byte>(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); | ||
|
||
string result = Encoding.UTF8.GetString(buffer); | ||
|
||
Assert.Equal("ImageSharp", result); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.