equiv-index.spec.ts 575 B

123456789101112131415161718
  1. /**
  2. * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { EquivalenceClasses } from '../util'
  7. describe('equiv-classes', () => {
  8. it('integer mod classes', () => {
  9. const cls = EquivalenceClasses<number, number>(x => x % 2, (a, b) => (a - b) % 2 === 0);
  10. for (let i = 0; i < 6; i++) cls.add(i, i);
  11. expect(cls.groups.length).toBe(2);
  12. expect(cls.groups[0]).toEqual([0, 2, 4]);
  13. expect(cls.groups[1]).toEqual([1, 3, 5]);
  14. });
  15. });