Skip to content

Commit

Permalink
test: add a sanity test
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh committed Jun 15, 2024
1 parent 096d2aa commit ed6832f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions matching/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ pathfinding = "4.9.1"

[dev-dependencies]
uuid = { workspace = true }
parsing = { path = "../parsing" }
55 changes: 55 additions & 0 deletions matching/tests/perfect_matching.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use matching::matching_configuration::MatchingConfiguration;
use model::language::Language;
use parsing::ParserConfiguration;

#[test]
fn the_perfect_matching_calculation_is_correct() -> Result<(), Box<dyn std::error::Error>> {
let config = ParserConfiguration::from(Language::Java);
let left = parsing::parse_string(
r#"""
public class Main {
static {
int x = 2;
}
public static void main() {
int a = 0;
}
public static void teste() {
}
}
"""#,
&config,
)?;

let right = parsing::parse_string(
r#"""
public class Main {
public static void teste() {
}
static {
int x = 2;
}
public static void main() {
int a = 0;
}
}
"""#,
&config,
)?;

let matching_configuration = MatchingConfiguration::from(Language::Java);
let matchings = matching::calculate_matchings(&left, &right, &matching_configuration);
assert!(
matchings
.get_matching_entry(&left, &right)
.unwrap()
.is_perfect_match
);
Ok(())
}

0 comments on commit ed6832f

Please sign in to comment.