Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
Create a function that takes a string and returns the number of vowels in that string.
function vowels(str) {
//code here
}
// 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");
describe("Solution", function() {
it("should test for something", function() {
// Test.assertEquals(1 + 1, 2);
// assert.strictEqual(1 + 1, 2);
});
});
Where is waldo?
console.log("Waldo");
// 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");
describe("Solution", function() {
it("should test for waldo", function() {
// Test.assertEquals(1 + 1, 2);
// assert.strictEqual(1 + 1, 2);
});
});
• ConvertToInt
You will receive a text in which you need to convert to an int.
Input example: "105"
Output example: 105
All input will be valid numbers.
• TransformMinusIntoPlus
You will receive a text in which contains a single minus which needs to be replaced by a plus.
Input example: "111-333"
Output example: "111+333"
• ConvertToDouble
You will receive a text in which you need to convert to a double.
Input example: "15,2"
Output example: 15.2
All input will be numbers with either separator: , or .
• ReturnNumbersAsArray
You will receive a string with numbers which you will need to convert to an array of int.
Input example: "10 20 30 40 50"
Output Example: [10, 20, 30, 40, 50]
The input will always be valid numbers.
• ReturnNumbersAsString
You will receive an int array with numbers which you will need to convert to a single
string following the output example
Input example: [10, 20, 30, 40, 50]
Output Example: "10, 20, 30, 40, 50"
• RemoveDecimalPlace
You will be given a decimal number which you must remove the decimal places
Input example: 10.2
Output example: 10
• EquationResult
You will be given a text wich contains a equation with 2 numbers and one operator: + - * /
You should return the result of the equation
Input example: "10 + 2"
Output example: 12
All input will be valid equations.
If a division by zero would occur, you should return the constant double.NaN
public class Basic1
{
public static int ConvertToInt(string numberAsText)
{
return 0;
}
public static string TransformMinusIntoPlus(string text)
{
return "";
}
public static double ConvertToDouble(string numberAsText)
{
return 0;
}
public static int[] ReturnNumbersAsArray(string text)
{
return null;
}
public static string ReturnNumbersAsString(int [] numbers)
{
return "";
}
public static decimal RemoveDecimalPlace(decimal number)
{
return 0;
}
public static double EquationResult(string equation)
{
return 0;
}
}
namespace Solution {
using NUnit.Framework;
using System;
[TestFixture]
public class SolutionTest
{
[Test]
public void TestConvertToInt()
{
Assert.AreEqual(1, Basic1.ConvertToInt("1"));
Assert.AreEqual(-1, Basic1.ConvertToInt("-1"));
Assert.AreEqual(99, Basic1.ConvertToInt("99"));
Assert.AreEqual(2, Basic1.ConvertToInt("02"));
Assert.AreEqual(7, Basic1.ConvertToInt("007"));
}
[Test]
public void TestTransformMinusIntoPlus()
{
Assert.AreEqual("111+333", Basic1.TransformMinusIntoPlus("111-333"));
Assert.AreEqual("19+8745", Basic1.TransformMinusIntoPlus("19-8745"));
Assert.AreEqual("897+", Basic1.TransformMinusIntoPlus("897-"));
Assert.AreEqual("+", Basic1.TransformMinusIntoPlus("-"));
Assert.AreEqual("1+5", Basic1.TransformMinusIntoPlus("1-5"));
Assert.AreEqual("+1", Basic1.TransformMinusIntoPlus("-1"));
}
[Test]
public void TestConvertToDouble()
{
Assert.AreEqual(10.0, Basic1.ConvertToDouble("10"));
Assert.AreEqual(22.3, Basic1.ConvertToDouble("22.3"));
Assert.AreEqual(-7, Basic1.ConvertToDouble("-7"));
Assert.AreEqual(89, Basic1.ConvertToDouble("89,0"));
Assert.AreEqual(-8.9, Basic1.ConvertToDouble("-8,9"));
Assert.AreEqual(99.3, Basic1.ConvertToDouble("99.3"));
Assert.AreEqual(2.3, Basic1.ConvertToDouble("2,3"));
Assert.AreEqual(0, Basic1.ConvertToDouble("0.0"));
Assert.AreEqual(-19.8, Basic1.ConvertToDouble("-19.8"));
}
[Test]
public void TestReturnNumbersAsArray()
{
Assert.AreEqual(new int[] {10, 20, 30, 40, 50}, Basic1.ReturnNumbersAsArray("010 20 30 40 50"));
Assert.AreEqual(new int[] {44, 33, 55, 66, 89}, Basic1.ReturnNumbersAsArray("44 33 0055 66 89"));
Assert.AreEqual(new int[] {-1, 27, 987, -98, 98}, Basic1.ReturnNumbersAsArray("-1 27 987 -98 98"));
Assert.AreEqual(new int[] {67, 0, -10, -30, 67}, Basic1.ReturnNumbersAsArray("67 00 -10 -30 67"));
}
[Test]
public void TestReturnNumbersAsString()
{
Assert.AreEqual("10, 20, 30, 40, 50", Basic1.ReturnNumbersAsString(new int[] {10, 20, 30, 40, 50}));
Assert.AreEqual("44, 33, 55, 66, 89", Basic1.ReturnNumbersAsString(new int[] {44, 33, 55, 66, 89}));
Assert.AreEqual("-1, 27, 987, -98, 98", Basic1.ReturnNumbersAsString(new int[] {-1, 27, 987, -98, 98}));
Assert.AreEqual("67, 0, -10, -30, 67", Basic1.ReturnNumbersAsString(new int[] {67, 0, -10, -30, 67}));
}
[Test]
public void TestRemoveDecimalPlace()
{
Assert.AreEqual(0.0d, Basic1.RemoveDecimalPlace(0.0m));
Assert.AreEqual(10.0d, Basic1.RemoveDecimalPlace(10.2m));
Assert.AreEqual(-20, Basic1.RemoveDecimalPlace(-20.3m));
Assert.AreEqual(-789, Basic1.RemoveDecimalPlace(-789.954m));
Assert.AreEqual(347, Basic1.RemoveDecimalPlace(347.999m));
Assert.AreEqual(decimal.MaxValue, Basic1.RemoveDecimalPlace(decimal.MaxValue));
Assert.AreEqual(decimal.MinValue, Basic1.RemoveDecimalPlace(decimal.MinValue));
}
[Test]
public void TestEquationResult()
{
Assert.AreEqual(8, Basic1.EquationResult("10 - 2"));
Assert.AreEqual(-8, Basic1.EquationResult("-10 - -2"));
Assert.AreEqual(8, Basic1.EquationResult("+10 - +2"));
Assert.AreEqual(0, Basic1.EquationResult("+0 - -0"));
Assert.AreEqual(int.MaxValue - 1, Basic1.EquationResult(int.MaxValue + " - 1"));
Assert.AreEqual(12, Basic1.EquationResult("10 + 2"));
Assert.AreEqual(995, Basic1.EquationResult("999 + -4"));
Assert.AreEqual(-17, Basic1.EquationResult("-15 + -2"));
Assert.AreEqual(30, Basic1.EquationResult("-70 + 100"));
Assert.AreEqual(20, Basic1.EquationResult("10 * 2"));
Assert.AreEqual(-20, Basic1.EquationResult("-10 * 2"));
Assert.AreEqual(20, Basic1.EquationResult("-10 * -2"));
Assert.AreEqual(0, Basic1.EquationResult("-10 * 0"));
Assert.AreEqual(5, Basic1.EquationResult("10 / 2"));
Assert.AreEqual(-5, Basic1.EquationResult("10 / -2"));
Assert.AreEqual(5, Basic1.EquationResult("-10 / -2"));
Assert.AreEqual(33.333333333333336d, Basic1.EquationResult("100 / 3"));
Assert.AreEqual(double.NaN, Basic1.EquationResult("100 / 0"));
}
}
}
I had trouble with the kata sum of a sequence, hard-core version. After looking at the solutions, I saw that the solutions used were more mathematical/ formula based rather than computation based.
I was hoping some of you can help make my, rather simplistic, code prettier without losing efficiency.
def sequence_sum(b, e, s):
sum = 0
if s >= 0:
while b <= e:
sum += b
b += s
else:
while b > e:
sum += b
b += s
return sum
import codewars_test as test
from solution import sequence_sum
@test.describe("Tests")
def test_group():
@test.it("Basic tests")
def test_case():
test.assert_equals(sequence_sum(2, 6, 2), 12)
test.assert_equals(sequence_sum(1, 5, 1), 15)
test.assert_equals(sequence_sum(1, 5, 3), 5)
test.assert_equals(sequence_sum(0, 15, 3), 45)
test.assert_equals(sequence_sum(16, 15, 3), 0)
test.assert_equals(sequence_sum(2, 24, 22), 26)
test.assert_equals(sequence_sum(2, 2, 2), 2)
test.assert_equals(sequence_sum(2, 2, 1), 2)
test.assert_equals(sequence_sum(1, 15, 3), 35)
test.assert_equals(sequence_sum(15, 1, 3), 0)
Practicing if else statements
using System;
public class Kumite
{
public bool MoreThan14(int num) {
// Create an integer variable with the value 14
// return true if your variable is bigger than num
}
// If the food is nasi lemak, return meal
// If the food is burger, return meal
// If the food is cendol or ice cream, return dessert
public string MealOrDessert(string food) {
return;
}
}
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void AmIOlderTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual(true, kumite.MoreThan14(5));
Assert.AreEqual(false, kumite.MoreThan14(22));
Assert.AreEqual(true, kumite.MoreThan14(2));
}
[Test]
public void MealOrDessertTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual("meal", kumite.MealOrDessert("nasi lemak"));
Assert.AreEqual("meal", kumite.MealOrDessert("burger"));
Assert.AreEqual("dessert", kumite.MealOrDessert("cendol"));
Assert.AreEqual("dessert", kumite.MealOrDessert("ice cream"));
}
}
}
using System;
public class Kumite
{
public void BasicVariables(int v) {
int count = 0;
// Write the name of the variable to the log
Console.WriteLine("<change this>");
// Write the type of the variable to the log
Console.WriteLine("<change this>");
// set the value of the variable to v (see the function parameters)
// <code here>
// Write the variable to the log
// <code here>
}
public string NamaeWa(string str) {
// Return "My name is <str>"
return "<change this>";
}
}
namespace Solution {
using NUnit.Framework;
using System;
using System.IO;
[TestFixture]
public class SolutionTest
{
[Test]
public void BasicVariablesTest()
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);
Kumite kumite = new Kumite();
kumite.BasicVariables(12);
string [] output = stringWriter.ToString().Split("\n");
Assert.AreEqual("count", output[0].Trim());
Assert.AreEqual("int", output[1].Trim());
Assert.AreEqual("12", output[2].Trim());
}
[Test]
public void NamaeWaTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual("My name is Taki", kumite.NamaeWa("Taki").Trim());
}
}
}
using System;
public class Kumite
{
public void PrintAnArray(string [] words) {
// Write all the words to the console
}
public int SumTheIntegers(int [] nums) {
// Add up all the integers and return the sum
}
}
namespace Solution {
using NUnit.Framework;
using System;
using System.IO;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
//[Test]
public void PrintAnArrayTest()
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);
Kumite kumite = new Kumite();
string [] words = {"An", "array", "of", "strings"};
kumite.PrintAnArray(words);
string [] output = stringWriter.ToString().Split("\n");
Assert.AreEqual("An", output[0].Trim());
Assert.AreEqual("array", output[1].Trim());
Assert.AreEqual("of", output[2].Trim());
Assert.AreEqual("strings", output[3].Trim());
}
[Test]
public void SumTheIntegersTest()
{
Kumite kumite = new Kumite();
int [] nums = {10, 9, 8, 4, 5};
Assert.AreEqual(36, kumite.SumTheIntegers(nums));
}
}
}
• ConvertTextToLong
You will receive a text which you need to convert to a long.
Input example: "105"
Output example: 105
All input will be valid numbers
• ConvertTextToDecimal
You will receive a text which you need to convert to a decimal
Input example: "30.7"
Output example: 30.7
All input will be valid numbers
• ConvertIntToLong
You will receive long which you need to convert to an int
Input example: 57
Output example: 57
• ToUpperCaseArray
You need to return a string array, upper casing every world
Input example: "hello world"
Output Example: ["HELLO", "WORLD"]
All text will contain a single space.
Spaces can occur in the begining or ending of the string
• ToLowerCaseString
Lower case every word in the given aray and return a string with all words separated by a single space.
Remove the spaces that can occur in the beginning or ending of a word.
Input example: ["HELLO", "WORLD"]
Output Example: "hello world"
All text will contain a single space.
• IsUpperCase
Based on a given text, you should:
Return 1 if all letters are upper case.
Return 0 if at least one letter is lower case
Return -1 if the text is either null, empty or only white spaces
Input example: "HELLO"
Output Example: 1
• RemoveUnnecessarySpaces
You need to remove all unecessary spaces from the given text
Including spaces in the beginning and ending of the text
Double or more spaces between the words
Input example: " Hello world "
Output Example: "Hello world"
public class Basic
{
public static long ConvertTextToLong(string numberAsText)
{
return 0;
}
public static decimal ConvertTextToDecimal(string numberAsText)
{
return 0;
}
public static long ConvertIntToLong(int number)
{
return 0;
}
public static string[] ToUpperCaseArray(string text)
{
return null;
}
public static string ToLowerCaseString(string[] words)
{
return null;
}
public static int IsUpperCase(string text)
{
return 0;
}
public static string RemoveUnnecessarySpaces(string text)
{
return null;
}
}
namespace Solution
{
using NUnit.Framework;
using System;
[TestFixture]
public class SolutionTest
{
[Test]
public void TestConvertTextToLong()
{
Assert.AreEqual(1L, Basic.ConvertTextToLong("1"));
Assert.AreEqual(-1L, Basic.ConvertTextToLong("-1"));
Assert.AreEqual(99L, Basic.ConvertTextToLong("99"));
Assert.AreEqual(2L, Basic.ConvertTextToLong("02"));
Assert.AreEqual(7L, Basic.ConvertTextToLong("007"));
Assert.AreEqual(long.MaxValue, Basic.ConvertTextToLong("" + long.MaxValue));
}
[Test]
public void TestConvertTextToDecimal()
{
Assert.AreEqual(1m, Basic.ConvertTextToDecimal("1"));
Assert.AreEqual(-1m, Basic.ConvertTextToDecimal("-1"));
Assert.AreEqual(99m, Basic.ConvertTextToDecimal("99"));
Assert.AreEqual(2m, Basic.ConvertTextToDecimal("02"));
Assert.AreEqual(7m, Basic.ConvertTextToDecimal("007"));
Assert.AreEqual(decimal.MaxValue, Basic.ConvertTextToDecimal("" + decimal.MaxValue));
}
[Test]
public void TestConvertIntToLong()
{
Assert.AreEqual(1L, Basic.ConvertIntToLong(1));
Assert.AreEqual(-99L, Basic.ConvertIntToLong(-99));
Assert.AreEqual(0L, Basic.ConvertIntToLong(0));
Assert.AreEqual(3215487L, Basic.ConvertIntToLong(3215487));
Assert.AreEqual(-3215487L, Basic.ConvertIntToLong(-3215487));
Assert.AreEqual(int.MaxValue, Basic.ConvertIntToLong(int.MaxValue));
}
[Test]
public void TestToUpperCaseArray()
{
Assert.AreEqual(new string[] {"HELLO", "WORLD"}, Basic.ToUpperCaseArray("HELLO WORLD"));
Assert.AreEqual(new string[] {"HELLO", "WORLD"}, Basic.ToUpperCaseArray("hello World"));
Assert.AreEqual(new string[] {"HELLO", "WORLD"}, Basic.ToUpperCaseArray(" hello World "));
Assert.AreEqual(new string[] {"TIME", "IS", "MONEY", "FRIEND"}, Basic.ToUpperCaseArray("TIME is money frIENd"));
Assert.AreEqual(new string[] {"THE", "APPLE", "IS", "VERY", "JUICE"}, Basic.ToUpperCaseArray("the apple is very juice"));
Assert.AreEqual(new string[] {"A", "B", "1", "2", "C"}, Basic.ToUpperCaseArray(" A b 1 2 c"));
Assert.AreEqual(new string[] {"AB12C"}, Basic.ToUpperCaseArray("Ab12c"));
Assert.AreEqual(new string[] {""}, Basic.ToUpperCaseArray(" "));
}
[Test]
public void TestToLowerCaseString()
{
Assert.AreEqual("hello world", Basic.ToLowerCaseString(new string[] {"hello", "world"}));
Assert.AreEqual("hello world", Basic.ToLowerCaseString(new string[] {"HELLO", "WORLD"}));
Assert.AreEqual("", Basic.ToLowerCaseString(new string[] {}));
Assert.AreEqual("the apple is very juice", Basic.ToLowerCaseString(new string[] {"The", "Apple", "IS", "VERY", "juice"}));
Assert.AreEqual("a b c d e f g h i j k", Basic.ToLowerCaseString(new string[] {"A", "b", "C", "D", "E", "f", "G", "h", "i", "j", "K"}));
}
[Test]
public void TestIsUpperCase()
{
Assert.AreEqual(1, Basic.IsUpperCase("HELLO"));
Assert.AreEqual(1, Basic.IsUpperCase(" HELLO "));
Assert.AreEqual(1, Basic.IsUpperCase(" HELLO WORLD "));
Assert.AreEqual(0, Basic.IsUpperCase("hello"));
Assert.AreEqual(0, Basic.IsUpperCase("HeLLo"));
Assert.AreEqual(0, Basic.IsUpperCase(" HeLLo "));
Assert.AreEqual(0, Basic.IsUpperCase(" HELLO wORLD "));
Assert.AreEqual(0, Basic.IsUpperCase(" Hello wOrLD "));
Assert.AreEqual(-1, Basic.IsUpperCase(" "));
Assert.AreEqual(-1, Basic.IsUpperCase(" "));
Assert.AreEqual(-1, Basic.IsUpperCase(""));
Assert.AreEqual(-1, Basic.IsUpperCase(string.Empty));
Assert.AreEqual(-1, Basic.IsUpperCase(null));
}
[Test]
public void TestRemoveUnnecessarySpaces()
{
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces("Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces("Hello world "));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world "));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world "));
Assert.AreEqual("the apple is very juice", Basic.RemoveUnnecessarySpaces(" the apple is very juice "));
Assert.AreEqual("", Basic.RemoveUnnecessarySpaces(" "));
Assert.AreEqual("", Basic.RemoveUnnecessarySpaces(" "));
}
}
}
function promedi(n1,n2,n3,n4){
var prom=(n1,n2,n3,n4 (4/4))
return(prom)
}
// 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");
describe("Solution", function() {
it("should test for something", function() {
// Test.assertEquals(1 + 1, 2);
// assert.strictEqual(1 + 1, 2);
});
});
• ToLowerCaseArray
You need to return a string array, lowering the case of every world.
Remove the spaces that can occur in the beginning or ending of a word.
Input example: "HELLO WORLD"
Output Example: ["hello", "world"]
All text will contain a single space as separator
• ToUpperCaseString
Upper case every word in the aray and return a string with the words separated by a single space.
Remove the spaces that can occur in the beginning or ending of a word.
Input example: ["HELLO", "WORLD"]
Output Example: "hello world"
• RemoveUnnecessarySpaces
You need to remove all unecessary spaces from the given text
Including spaces in the beginning and ending of the text
Double or more spaces between the words
Input example: " Hello world "
Output Example: "Hello world"
• GetTheFirstLetter
Return the first letter of the given word
Input example: " Hello"
Output Example: "H"
• UpperCaseFirstLetter
You should transform the given text so the first letter is upper case and the other are lower case.
Remove the spaces that can occur in the beginning or ending of a word.
Input example: "hello"
Output Example: "Hello"
• ToCamelCase
You need to remove every space and also upper case the first letter of every world
Input example: "the apple is very juice "
Output Example: "TheAppleIsVeryJuice"
Spaces can occur multiple time including in the begining and ending
public class Basic
{
public static string[] ToLowerCaseArray(string text)
{
return null;
}
public static string ToUpperCaseString(string[] words)
{
return null;
}
public static string RemoveUnnecessarySpaces(string text)
{
return null;
}
public static string GetTheFirstLetter(string text)
{
return null;
}
public static string UpperCaseFirstLetter(string text)
{
return null;
}
public static string ToCamelCase(string text)
{
return null;
}
}
namespace Solution
{
using NUnit.Framework;
using System;
[TestFixture]
public class SolutionTest
{
[Test]
public void TestToLowerCaseArray()
{
Assert.AreEqual(new string[] {"hello", "world"}, Basic.ToLowerCaseArray("HELLO WORLD"));
Assert.AreEqual(new string[] {"hello", "world"}, Basic.ToLowerCaseArray("hello World"));
Assert.AreEqual(new string[] {"hello", "world"}, Basic.ToLowerCaseArray(" hello World "));
Assert.AreEqual(new string[] {"time", "is", "money", "friend"}, Basic.ToLowerCaseArray("TIME is money frIENd"));
Assert.AreEqual(new string[] {"the", "apple", "is", "very", "juice"}, Basic.ToLowerCaseArray("the apple is very juice"));
Assert.AreEqual(new string[] {"a", "b", "1", "2", "c"}, Basic.ToLowerCaseArray(" A b 1 2 c"));
Assert.AreEqual(new string[] {"ab12c"}, Basic.ToLowerCaseArray("Ab12c"));
Assert.AreEqual(new string[] {""}, Basic.ToLowerCaseArray(" "));
}
[Test]
public void TestToUpperCaseString()
{
Assert.AreEqual("HELLO WORLD", Basic.ToUpperCaseString(new string[] {"hello", "world"}));
Assert.AreEqual("HELLO WORLD", Basic.ToUpperCaseString(new string[] {"HELLO", "WORLD"}));
Assert.AreEqual("", Basic.ToUpperCaseString(new string[] {}));
Assert.AreEqual("THE APPLE IS VERY JUICE", Basic.ToUpperCaseString(new string[] {"The", "Apple", "IS", "VERY", "juice"}));
Assert.AreEqual("A B C D E F G H I J K", Basic.ToUpperCaseString(new string[] {"A", "b", "C", "D", "E", "f", "G", "h", "i", "j", "K"}));
}
[Test]
public void TestRemoveUnnecessarySpaces()
{
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces("Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces("Hello world "));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world"));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world "));
Assert.AreEqual("Hello world", Basic.RemoveUnnecessarySpaces(" Hello world "));
Assert.AreEqual("the apple is very juice", Basic.RemoveUnnecessarySpaces(" the apple is very juice "));
Assert.AreEqual("", Basic.RemoveUnnecessarySpaces(" "));
Assert.AreEqual("", Basic.RemoveUnnecessarySpaces(" "));
}
[Test]
public void TestGetTheFirstLetter()
{
Assert.AreEqual("h", Basic.GetTheFirstLetter("hello"));
Assert.AreEqual("H", Basic.GetTheFirstLetter("Hello"));
Assert.AreEqual("W", Basic.GetTheFirstLetter("World"));
Assert.AreEqual("w", Basic.GetTheFirstLetter("world"));
Assert.AreEqual("a", Basic.GetTheFirstLetter("apple"));
Assert.AreEqual("A", Basic.GetTheFirstLetter("Apple"));
Assert.AreEqual("h", Basic.GetTheFirstLetter(" hello"));
Assert.AreEqual("H", Basic.GetTheFirstLetter(" Hello"));
Assert.AreEqual("W", Basic.GetTheFirstLetter(" World"));
Assert.AreEqual("w", Basic.GetTheFirstLetter( "world"));
Assert.AreEqual("a", Basic.GetTheFirstLetter(" apple"));
Assert.AreEqual("A", Basic.GetTheFirstLetter(" Apple"));
Assert.AreEqual("h", Basic.GetTheFirstLetter(" hello "));
Assert.AreEqual("H", Basic.GetTheFirstLetter(" Hello "));
Assert.AreEqual("W", Basic.GetTheFirstLetter(" World"));
Assert.AreEqual("w", Basic.GetTheFirstLetter("world "));
Assert.AreEqual("a", Basic.GetTheFirstLetter(" apple "));
Assert.AreEqual("A", Basic.GetTheFirstLetter(" Apple "));
}
[Test]
public void TestUpperCaseFirstLetter()
{
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("hello"));
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("Hello"));
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("HelLo"));
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("HELLO"));
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("hELLO"));
Assert.AreEqual("Hello", Basic.UpperCaseFirstLetter("hELLo"));
}
[Test]
public void TestToCamelCase()
{
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase("the apple is very juice"));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" the apple is very juice"));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" the apple is very juice "));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" the apple is very juice "));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" the apple is very juice"));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" the apple is very juice "));
Assert.AreEqual("TheAppleIsVeryJuice", Basic.ToCamelCase(" The aPple iS VERY JuicE "));
}
}
}