Skip to content

Commit

Permalink
Fix unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Feb 21, 2025
1 parent 4b59ba1 commit 6028ab6
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crates/codebook/tests/examples/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
)

func main() {
// I'm bad at speling alice
fmt.Println("Hello, Wolrd!")
var alicz = "Alicz"
fmt.Println("Hello, " + alicz)
var rsvp = "RSVP"
fmt.Println("Hello, " + rsvp)
}

func mispeledFuncion() string {
return ""
}
10 changes: 10 additions & 0 deletions crates/codebook/tests/examples/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Documentt</title>
</head>
<body>
Spelin sor good. Wolrd
</body>
</html>
69 changes: 69 additions & 0 deletions crates/codebook/tests/examples/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Calculater function with spelling mistakes
function calculater(numbr1, numbr2, operashun) {
let resalt;

switch (operashun) {
case "additshun":
resalt = numbr1 + numbr2;
break;
case "substractshun":
resalt = numbr1 - numbr2;
break;
case "multiplacation":
resalt = numbr1 * numbr2;
break;
case "divishun":
if (numbr2 === 0) {
return "Cannot divde by zero";
}
resalt = numbr1 / numbr2;
break;
default:
return "Invalid operashun";
}

return resalt;
}

// Funktion to validate user inputt
function validateInputt(userInputt) {
if (typeof userInputt !== "number") {
console.logg("Pleese enter a valid numbr");
return;
}

return;
}

// Example usege
const firstNumbr = 10;
const secandNumbr = 5;

if (validateInputt(firstNumbr) && validateInputt(secandNumbr)) {
const summ = calculater(firstNumbr, secandNumbr, "additshun");
console.logg(`The summ is: ${summ}`);
}

// Array of numbrs with spelling mistakes
const arraOfNumbrs = [1, 2, 3, 4, 5];

// Funcshun to prosess array
function prosessArray(arr) {
let totel = 0;

for (let i = 0; i < arr.lenght; i++) {
totel += arr[i];
}
return totel;
}

// Object with propertys
const userAccaunt = {
usrname: "JohnDoe",
passwrd: "12345",
emale: "john@example.com",
ballance: 1000,
};

// Exportt the funcsions
export { calculater, validateInputt, prosessArray };
5 changes: 5 additions & 0 deletions crates/codebook/tests/examples/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
I'm bvd at splellin Wolrd wolrd
hello regulr

Some DNA:
ATGCATCG
20 changes: 20 additions & 0 deletions crates/codebook/tests/examples/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Example Pthon fie
def main():
print("Hello, Wolrd!")


class JSONLD:
def jsonld(self):
return self.bad_spelin()

def bad_spelin(self):
return "Spelling is hard"


multi_line_string = """This is a multi-line string
that spans multiple linest
and is enclosed in triple quotes"""


if __name__ == "__main__":
main()
9 changes: 9 additions & 0 deletions crates/codebook/tests/examples/example.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn calclate_user_age(birt_date: String, get_curent_date: String) -> String {
// This is an example_function that calculates age
let usr_age = format!("{}{}", get_curent_date, birt_date);
usr_age
}

fn main() {
calculat_user_age("hi".to_string(), "jalopin".to_string());
}
45 changes: 45 additions & 0 deletions crates/codebook/tests/examples/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Funktion to validate user inputt
function validateInputt(userInputt: number | string) {
if (typeof userInputt !== "number") {
console.log("Pleese enter a valid numbr");
return false;
}

return true;
}

const multiLineString = `This is a multi-line string
spanning multiple lines
with some spelling mistkes`;

// Example usege
const firstNumbr = 10;
const secandNumbr = 5;

// Array of numbrs with spelling mistakes
const arraOfNumbrs = [1, 2, 3, 4, 5];

/*
Funcshun to prosess array
another linet
*/
function prosessArray(arr: number[]) {
let totel = 0;

for (let i = 0; i < arr.length; i++) {
totel += arr[i];
}

return totel;
}

// Object with propertys
const userAccaunt = {
usrname: "JohnDoe",
passwrd: "12345",
emale: "john@example.com",
ballance: 1000,
};

// Exportt the funcsions
export { validateInputt, prosessArray };
1 change: 1 addition & 0 deletions crates/codebook/tests/examples/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm bd at Splellin
2 changes: 1 addition & 1 deletion crates/codebook/tests/test_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod utils;

fn example_file_path(file: &str) -> String {
// get root of the project through CARGO_MANIFEST_DIR
format!("../../examples/{}", file)
format!("tests/examples/{}", file)
}

#[test]
Expand Down

0 comments on commit 6028ab6

Please sign in to comment.