Move History

Fork Selected
  • Code
    fn reverse_string(word: &str) -> String {
        word.chars().rev().collect()
    }
    Test Cases
    #[test]
    fn test_monkey() {
        assert_eq!(reverse_string("monkey"),"yeknom");
    }
    
    #[test]
    fn test_home() {
        assert_eq!(reverse_string("home"), "emoh");
    }
    
    #[test]
    fn test_pneumonoultramicroscopicsilicovolcanoconiosis() {
        assert_eq!(reverse_string("pneumonoultramicroscopicsilicovolcanoconiosis"), "sisoinoconaclovociliscipocsorcimartluonomuenp");
    }
    
  • Code
    • public class ReverseString {
    • public static String reverseString(String word) {
    • String reversedWord = "";
    • for (int i = 0; i < word.length(); i++) {
    • reversedWord = word.charAt(i) + reversedWord;
    • }
    • return reversedWord;
    • }
    • fn reverse_string(word: &str) -> String {
    • word.chars().rev().collect()
    • }
    Test Cases
    • import org.junit.jupiter.api.Test;
    • import static org.junit.jupiter.api.Assertions.assertEquals;
    • #[test]
    • fn test_monkey() {
    • assert_eq!(reverse_string("monkey"),"yeknom");
    • }
    • #[test]
    • fn test_home() {
    • assert_eq!(reverse_string("home"), "emoh");
    • }
    • class ReverseStringTest {
    • @Test
    • public void testMonkey() {
    • assertEquals("yeknom", "monkey");
    • }
    • @Test
    • void testHome() {
    • assertEquals("emoh", "home");
    • }
    • @Test
    • void testPneumonoultramicroscopicsilicovolcanoconiosis() {
    • assertEquals("sisoinoconaclovociliscipocsorcimartluonomuenp", "pneumonoultramicroscopicsilicovolcanoconiosis");
    • }
    • #[test]
    • fn test_pneumonoultramicroscopicsilicovolcanoconiosis() {
    • assert_eq!(reverse_string("pneumonoultramicroscopicsilicovolcanoconiosis"), "sisoinoconaclovociliscipocsorcimartluonomuenp");
    • }