From c2a5b66318ecdbf2e570ef61f4d48c51f7e4fec2 Mon Sep 17 00:00:00 2001 From: Mikkel Kongsted Date: Fri, 22 Nov 2024 12:37:38 +0100 Subject: [PATCH] tdd survey --- surveys/code_coverage/program_2_phami_test.ts | 10 ++++++++++ surveys/code_coverage/program_2_teis_test.ts | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 surveys/code_coverage/program_2_phami_test.ts create mode 100644 surveys/code_coverage/program_2_teis_test.ts diff --git a/surveys/code_coverage/program_2_phami_test.ts b/surveys/code_coverage/program_2_phami_test.ts new file mode 100644 index 0000000..731a57e --- /dev/null +++ b/surveys/code_coverage/program_2_phami_test.ts @@ -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) +}); diff --git a/surveys/code_coverage/program_2_teis_test.ts b/surveys/code_coverage/program_2_teis_test.ts new file mode 100644 index 0000000..307a7aa --- /dev/null +++ b/surveys/code_coverage/program_2_teis_test.ts @@ -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); + + + +});