<commit_before><commit_msg>Adds unit test for rights<commit_after>using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace Tgstation.Server.Api.Rights.Tests
{
	/// <summary>
	/// Tests for <see cref="Rights"/>
	/// </summary>
	[TestClass]
	public sealed class TestRights
	{
		[TestMethod]
		public void TestAllPowerOfTwo()
		{
			var ulongType = typeof(ulong);
			foreach (var I in Enum.GetValues(typeof(RightsType)).Cast<RightsType>())
			{
				var expectedLog = -1;
				var rightType = RightsHelper.RightToType(I);
				foreach (var J in Enum.GetValues(rightType))
				{
					Assert.AreEqual(ulongType, Enum.GetUnderlyingType(rightType));
					var asUlong = (ulong)J;
					var isOne = asUlong == 1;
					if(!isOne)
						Assert.AreEqual(0U, asUlong % 2, String.Format("Enum {0} of {1} is not a power of 2!", Enum.GetName(rightType, asUlong), rightType));

					if (expectedLog > -1)
					{
						var log = Math.Log(asUlong, 2);
						if (log != expectedLog)
							Assert.Fail(String.Format("Expected Log2({1}) == {0} to come next for {2}, got {3} instead!", expectedLog, Enum.GetName(rightType, asUlong), rightType, log));
					}
					++expectedLog;
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.14380165289256197, 'fraction_numerical': 0.011570247933884297, 'mean_word_length': 3.4358974358974357, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3829727', 'n_tokens_mistral': 506, 'n_tokens_neox': 419, 'n_words': 99}