public Property InterleaveProperty(IList <int> xs, IList <int> ys) { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(PropExtensions.AndAll( PropExtensions.Label(xs.Count + ys.Count == res.Count(), "length"), PropExtensions.Label(xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count))), "zip xs"), PropExtensions.Label(ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count))), "zip ys"))); }
public void InterleaveTest() { var body = FSharpFunc <IList <int>, FSharpFunc <IList <int>, Property> > .FromConverter(xs => FSharpFunc <IList <int>, Property> .FromConverter(ys => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(PropExtensions.AndAll( PropExtensions.Label(xs.Count + ys.Count == res.Count(), "length"), PropExtensions.Label(xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count))), "zip xs"), PropExtensions.Label(ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count))), "zip ys"))); })); Check.One(Config, body); }
public Property InterleavePropertyFluent(IList <int> xsParam, IList <int> ysParam) { return(Spec .For(Any.Value(xsParam), Any.Value(ysParam), (xs, ys) => { var res = Interleaving.Interleave(xs, ys); return xs.Count + ys.Count == res.Count(); }).Label("length") .And((xs, ys) => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count))); }, "zip xs") .And((xs, ys) => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count))); }, "zip ys") .Build()); }
public void InterleaveTestFluent() { Spec .For(Any.OfType <IList <int> >(), Any.OfType <IList <int> >(), (xs, ys) => { var res = Interleaving.Interleave(xs, ys); return(xs.Count + ys.Count == res.Count()); }).Label("length") .And((xs, ys) => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count)))); }, "zip xs") .And((xs, ys) => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count)))); }, "zip ys") .Check(Configuration); }