Files
OpenRA/OpenRA.Test/OpenRA.Game/Sha1Tests.cs
let5sne.win10 9cf6ebb986
Some checks failed
Continuous Integration / Linux (.NET 8.0) (push) Has been cancelled
Continuous Integration / Windows (.NET 8.0) (push) Has been cancelled
Initial commit: OpenRA game engine
Fork from OpenRA/OpenRA with one-click launch script (start-ra.cmd)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 21:46:54 +08:00

36 lines
1.1 KiB
C#

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.That(expected, Is.EqualTo(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.That(expected, Is.EqualTo(actual));
}
}
}