tdd survey

This commit is contained in:
Mikkel Kongsted 2024-11-22 12:37:38 +01:00
parent 736953d9e9
commit c2a5b66318
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import { assertEquals } from "jsr:@std/assert";
import { stringToInt } from "./program_2.ts";
Deno.test("must work", () => {
assertEquals(stringToInt("0"), 0);
assertEquals(stringToInt(""), NaN);
assertEquals(stringToInt("0b10"), 2)
assertEquals(stringToInt("0x10"), 16)
assertEquals(stringToInt("010"), 8)
});

View File

@ -0,0 +1,18 @@
import { assertEquals } from "jsr:@std/assert";
import { stringToInt } from "./program_2.ts";
Deno.test("must work", () => {
assertEquals(stringToInt("0"), 0);
assertEquals(stringToInt("10"), 10);
assertEquals(stringToInt("30"), 30);
assertEquals(stringToInt("0xf"), 15);
assertEquals(stringToInt("0x1f"), 31);
assertEquals(stringToInt("0b110"), 6);
assertEquals(stringToInt("06"), 6);
assertEquals(stringToInt("060"), 6*8);
assertEquals(stringToInt(""), NaN);
assertEquals(stringToInt("10f"), NaN);
});