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); + + + +});