public void TestCompact(int count) { int[] data = new int[count]; int[] selected = new int[count]; for (int i = 0; i < count; i++) { data[i] = i; selected[i] = i % 2; } using (StructuredBuffer <int> buffer = new StructuredBuffer <int>(count)) using (StructuredBuffer <int> keys = new StructuredBuffer <int>(count)) { buffer.SetData(data); keys.SetData(selected); ScanCompact compactor = new ScanCompact(); compactor.Compact(buffer, keys, buffer.Count); int[] result = buffer.GetData(); for (int i = 0; i < count / 2; i++) { Assert.AreEqual(result[i], 2 * i + 1); } } }