1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Test utilities for full-dictionary integration tests.
//!
//! This module provides helpers for tests that require a fully-built MeCab-Ko
//! dictionary. In CI environments without the dictionary, these tests are
//! skipped gracefully rather than failing.
//!
//! # Environment Variable
//!
//! Set `MECAB_KO_FULL_DICT` to the path of a built dictionary directory
//! (one that contains `sys.dic`, `matrix.bin`, `unk.bin`, etc.) to enable
//! full-dictionary tests.
//!
//! # Examples
//!
//! ```rust,no_run
//! #[test]
//! fn test_with_full_dict() {
//! mecab_ko_core::full_dict_test!();
//!
//! let dict_path = mecab_ko_core::test_utils::full_dict_path().unwrap();
//! // ... use dict_path to load the dictionary ...
//! }
//! ```
/// Skips the current test when the `MECAB_KO_FULL_DICT` environment variable
/// is not set.
///
/// When the variable is set it must point to a directory that contains a
/// pre-built MeCab-Ko dictionary (`sys.dic`, `matrix.bin`, `unk.bin`, …).
///
/// # Usage
///
/// Place `full_dict_test!();` at the very top of a `#[test]` function body.
/// If the environment variable is absent the test prints a notice to `stderr`
/// and returns immediately without failing.
///
/// # Examples
///
/// ```rust,no_run
/// #[test]
/// fn test_tokenize_sentence() {
/// mecab_ko_core::full_dict_test!();
///
/// // Only reached when MECAB_KO_FULL_DICT is set.
/// let path = mecab_ko_core::test_utils::full_dict_path().unwrap();
/// assert!(path.exists());
/// }
/// ```
/// Returns the full-dictionary path from the `MECAB_KO_FULL_DICT` environment
/// variable, or `None` when the variable is not set.
///
/// # Examples
///
/// ```rust
/// // When MECAB_KO_FULL_DICT is not set, this returns None.
/// let path = mecab_ko_core::test_utils::full_dict_path();
/// // path is None in a test environment without the env var
/// ```