classify_unit

Function classify_unit 

Source
pub fn classify_unit(
    unit: &SemanticUnit,
    path: &Path,
    config: &Config,
) -> CodeType
Expand description

Classifies a semantic unit as production or test code

§Arguments

  • unit - The semantic unit to classify
  • path - Path to the file containing the unit
  • config - Configuration

§Returns

Classification of the code

§Examples

use std::path::Path;

use rust_diff_analyzer::{
    classifier::classify_unit,
    config::Config,
    types::{LineSpan, SemanticUnit, SemanticUnitKind, Visibility},
};

let unit = SemanticUnit::new(
    SemanticUnitKind::Function,
    "test_something".to_string(),
    Visibility::Private,
    LineSpan::new(1, 10),
    vec!["test".to_string()],
);

let config = Config::default();
let classification = classify_unit(&unit, Path::new("src/lib.rs"), &config);
assert!(classification == rust_diff_analyzer::types::CodeType::Test);