From 8a7d8ec24c3fd602790c519e7ba52a644b3bf3a2 Mon Sep 17 00:00:00 2001 From: Gator Date: Tue, 27 Dec 2022 11:24:46 +0100 Subject: [PATCH] test file for core --- tests/core.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/core.test.js diff --git a/tests/core.test.js b/tests/core.test.js new file mode 100644 index 0000000..355865b --- /dev/null +++ b/tests/core.test.js @@ -0,0 +1,18 @@ +import { describe, expect, test } from "vitest"; +import { evolve1d, create1dStateOneCell } from "src/modules/core.js"; +import { presetRuleset } from "src/modules/preset.js"; + +describe("Core", () => { + test("evolve1d, rules73, 9 cells", () => { + const state = [0, 0, 0, 0, 1, 0, 0, 0, 0]; + const got = evolve1d(state, presetRuleset[0].rules); + const valid = [1, 1, 1, 0, 0, 0, 1, 1, 1]; + expect(got.length).toBe(state.length); + expect(got).toEqual(valid); + }), + test("create1dStateOneCell, 49 cells", () => { + const got = create1dStateOneCell(49); + expect(got.length).toBe(49); + expect(got[24]).toBe(1); + }); +});