-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new method to convert byte array to lower case hex-string
added unit test update ToHex(byte[]) to support mono added punctuations to unit test summary and parameter description Replaced with Convert.ToHexString(), public ToHex() + use from Color.ToString() Adjusted back to a simpler mono compatible version only, with lowered allocation
- Loading branch information
Showing
3 changed files
with
69 additions
and
6 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,35 @@ | ||
using NUnit.Framework; | ||
using OpenRA.Primitives; | ||
|
||
namespace OpenRA.Test | ||
{ | ||
[TestFixture] | ||
sealed class Sha1Tests | ||
{ | ||
/// <summary> | ||
/// https://en.wikipedia.org/wiki/SHA-1#Examples_and_pseudocode. | ||
/// </summary> | ||
/// <param name="input">The input string.</param> | ||
/// <param name="expected">The expected hex string of the SHA1.</param> | ||
[TestCase("The quick brown fox jumps over the lazy dog", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12")] | ||
[TestCase("The quick brown fox jumps over the lazy cog", "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3")] | ||
[TestCase("", "da39a3ee5e6b4b0d3255bfef95601890afd80709")] | ||
public void Sha1HexConvert(string input, string expected) | ||
{ | ||
var actual = CryptoUtil.SHA1Hash(input); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestCase(0xFF0000FF, "0000FF")] | ||
[TestCase(0xFF00FFFF, "00FFFF")] | ||
[TestCase(0xFFFF00FF, "FF00FF")] | ||
[TestCase(0xAAFF00FF, "FF00FFAA")] | ||
public void ColorsToHex(uint value, string expected) | ||
{ | ||
var color = Color.FromArgb(value); | ||
var actual = color.ToString(); | ||
Assert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |