public class MyCalculator { public static int add(int a, int b) { return a + b; } }
namespace Solution{public class MyCalculator{public int Add(int a, int b){- public class MyCalculator {
- public static int add(int a, int b) {
- return a + b;
}- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void test() { assertEquals(5+7, MyCalculator.add(5, 7)); } }
using NUnit.Framework;using Solution;- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
namespace Tests{[TestFixture]public class MyCalculatorTests{[Test]public void Add_TwoNumbers_ReturnsSum(){// ArrangeMyCalculator calculator = new MyCalculator();int a = 5;int b = 7;int expectedResult = 12;- // TODO: Replace examples and use TDD by writing your own tests
// Actint actualResult = calculator.Add(a, b);// AssertAssert.AreEqual(expectedResult, actualResult);}- class SolutionTest {
- @Test
- void test() {
- assertEquals(5+7, MyCalculator.add(5, 7));
- }
public class Program { public static String helloWorld(boolean world) { if (world) { return "Hello, World"; } return "Goodbye, World"; } }
def hello_world(world):if world == True:return "Hello, World"return "Goodbye, World"- public class Program {
- public static String helloWorld(boolean world) {
- if (world) {
- return "Hello, World";
- }
- return "Goodbye, World";
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void test() { assertEquals("Hello, World", Program.helloWorld(true)); assertEquals("Goodbye, World", Program.helloWorld(false)); } }
import codewars_test as test# TODO Write testsimport solution # or from solution import example- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
# test.assert_equals(actual, expected, [optional] message)@test.describe("Example")def test_group():@test.it("test case")def test_case():test.assert_equals(1 + 1, 2)- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void test() {
- assertEquals("Hello, World", Program.helloWorld(true));
- assertEquals("Goodbye, World", Program.helloWorld(false));
- }
- }
public class Program { public static String digitToText(int digit) { final String[] nums = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; return nums[digit]; } }
const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']function digitToText(digit) {return nums[digit]}- public class Program {
- public static String digitToText(int digit) {
- final String[] nums = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
- return nums[digit];
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void test() { assertEquals("zero", Program.digitToText(0)); assertEquals("one", Program.digitToText(1)); assertEquals("two", Program.digitToText(2)); assertEquals("three", Program.digitToText(3)); assertEquals("four", Program.digitToText(4)); assertEquals("five", Program.digitToText(5)); assertEquals("six", Program.digitToText(6)); assertEquals("seven", Program.digitToText(7)); assertEquals("eight", Program.digitToText(8)); assertEquals("nine", Program.digitToText(9)); } }
// 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");- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
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)});});- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void test() {
- assertEquals("zero", Program.digitToText(0));
- assertEquals("one", Program.digitToText(1));
- assertEquals("two", Program.digitToText(2));
- assertEquals("three", Program.digitToText(3));
- assertEquals("four", Program.digitToText(4));
- assertEquals("five", Program.digitToText(5));
- assertEquals("six", Program.digitToText(6));
- assertEquals("seven", Program.digitToText(7));
- assertEquals("eight", Program.digitToText(8));
- assertEquals("nine", Program.digitToText(9));
- }
- }