Skip to content

Commit

Permalink
Create Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mintype committed Apr 6, 2024
1 parent 132ff01 commit 1498b56
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub fn translate(text: &str, from: &str, to: &str) -> String {
// placeholder
text.to_string()
}

pub fn translate_to_english(text: &str) -> String {
// placeholder
text.to_string()
}
28 changes: 28 additions & 0 deletions tests/translate_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use rust_translate::{translate_to_english, translate};

#[test]
fn test_translate() {
// Prepare the input parameters
let text = "Hello World";
let from = "en";
let to = "de";

// Call the function under test
let translated_text = translate(text, from, to);

// Check if the result is as expected
assert_eq!(translated_text, "Hallo Welt");
}

#[test]
fn test_translate_to_english() {
// Prepare the input parameters
let text = "Hallo Welt";

// Call the function under test
let translated_text = translate_to_english(text);

// Check if the result is as expected
assert_eq!(translated_text, "Hello World");
}

0 comments on commit 1498b56

Please sign in to comment.