const char *nums[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; const char* digit_to_text(int digit) { return nums[digit]; }
const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']function digitToText(digit) {return nums[digit]- const char *nums[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
- const char* digit_to_text(int digit) {
- return nums[digit];
- }
#include <criterion/criterion.h> const char* digit_to_text(int digit); Test(the_multiply_function, should_pass_all_the_tests_provided) { cr_assert_str_eq(digit_to_text(3), "three"); cr_assert_str_eq(digit_to_text(9), "nine"); cr_assert_str_eq(digit_to_text(0), "zero"); }
// Since Node 10, we're using Mocha.// You can use `chai` for assertions.const chai = require("chai");const assert = chai.assert;// Uncomment the following line to disable truncating failure messages for deep equals, do:// chai.config.truncateThreshold = 0;// Since Node 12, we no longer include assertions from our deprecated custom test framework by default.// Uncomment the following to use the old assertions:// const Test = require("@codewars/test-compat");- #include <criterion/criterion.h>
describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);assert.strictEqual(digitToText(1), 'one')assert.strictEqual(digitToText(2), 'two')assert.strictEqual(digitToText(3), 'three')assert.strictEqual(digitToText(4), 'four')assert.strictEqual(digitToText(5), 'five')assert.strictEqual(digitToText(6), 'six')assert.strictEqual(digitToText(7), 'seven')assert.strictEqual(digitToText(8), 'eight')assert.strictEqual(digitToText(9), 'nine')assert.strictEqual(digitToText(0), 'zero')assert.strictEqual(digitToText(11), undefined)});});- const char* digit_to_text(int digit);
- Test(the_multiply_function, should_pass_all_the_tests_provided) {
- cr_assert_str_eq(digit_to_text(3), "three");
- cr_assert_str_eq(digit_to_text(9), "nine");
- cr_assert_str_eq(digit_to_text(0), "zero");
- }