Sha256: 49f2ef192adb09bfdf253cc240a310f720fdfd247b338bea3b1c4f92df18eb0a
Contents?: true
Size: 1.48 KB
Versions: 28
Compression:
Stored size: 1.48 KB
Contents
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Generators.Input; using Generators.Output; namespace Generators.Exercises { public class VariableLengthQuantity : GeneratorExercise { protected override void UpdateCanonicalData(CanonicalData canonicalData) { foreach (var canonicalDataCase in canonicalData.Cases) { canonicalDataCase.UseVariableForExpected = true; canonicalDataCase.UseVariablesForInput = true; canonicalDataCase.Input["integers"] = FormatUInt32Array(canonicalDataCase.Input["integers"]); if (canonicalDataCase.Expected == null) canonicalDataCase.ExceptionThrown = typeof(InvalidOperationException); else canonicalDataCase.Expected = FormatUInt32Array(canonicalDataCase.Expected); } } private dynamic FormatUInt32Array(dynamic input) { var numbers = ToUInt32Array(input as IEnumerable); if (!numbers.Any()) { return new UnescapedValue("new uint[0]"); } return numbers.Select(number => new UnescapedValue(string.Format("0x{0:X}u", number))).ToArray(); } private IEnumerable<uint> ToUInt32Array(IEnumerable input) { foreach (var number in input) yield return Convert.ToUInt32(number.ToString()); } } }
Version data entries
28 entries across 28 versions & 1 rubygems