Skip to content

Commit

Permalink
git commit; git push; leave the building;
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed May 13, 2024
1 parent 50107b4 commit 5521acb
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 13 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ lto = true
debug = true

[dependencies]
translit = { version = "0.5.0", optional = true }
translit = {version = "0.5.0", optional = true }
regex = {version = "1.10.4", optional = true }

[features]
default = [
"text"
"transliteration",
"regexp"
]

text = ["translit"]
transliteration = ["translit"]
regexp = ["regex"]

File renamed without changes.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mod byond;
#[allow(dead_code)]
mod error;

#[cfg(feature = "text")]
pub mod text;
pub mod transliteration;
pub mod regexp;

#[cfg(not(target_pointer_width = "32"))]
compile_error!("rust-utils must be compiled for a 32-bit target");
19 changes: 19 additions & 0 deletions src/regexp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use regex::Regex;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn regexp_test() {
let pattern = r"(?i)\bго+л\b";

let re = Regex::new(pattern).unwrap();

let input = "Сука Гооооооооооооооол в гооооландские ворота.";

let output = re.replace_all(input, "поподание мячем");

assert_eq!(output, "Сука поподание мячем в гооооландские ворота.");
}
}
File renamed without changes.
5 changes: 2 additions & 3 deletions tests/dm-tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::process::{Command, Output};

#[cfg(feature = "text")]
#[test]
fn text() {
run_dm_tests("text");
fn transliteration() {
run_dm_tests("transliteration");
}

fn run_dm_tests(name: &str) {
Expand Down
10 changes: 5 additions & 5 deletions tests/dm/common.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "../../target/rust_utils.dm"

/world/New()
world.log << RUST_UTILS
for(var/func in typesof(/test/proc))
log << "[func] [copytext("------------------------------------------------------------------------", length("[func]"))]"
call(new /test, func)()
del src
world.log << "Rust is at [RUST_UTILS]"
for(var/func in typesof(/test/proc))
log << "[func] [copytext("------------------------------------------------------------------------", length("[func]"))]"
call(new /test, func)()
del src
1 change: 1 addition & 0 deletions tests/dm/text.dme → tests/dm/transliteration.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ var/test_cyr_text = "Смоке!"

/test/proc/check_latin_to_cyrrilic()
ASSERT(rustutils_latin_to_cyrillic(test_latin_text) == test_cyr_text)
ASSERT(rustutils_cyrillic_to_latin(test_cyr_text) == test_latin_text)

0 comments on commit 5521acb

Please sign in to comment.