raw
1use super::super::environment_variable::*;
2use crate::ast::*;
3
4#[test]
5fn test_basic_env_var() {
6 let result = environment_variable("PKG_CONFIG_PATH").unwrap();
7 assert_eq!(result.0, "");
8 assert_eq!(result.1, Inline::Text("PKG_CONFIG_PATH".to_string()));
9}
10
11#[test]
12fn test_mixed_case_env_var() {
13 let result = environment_variable("CMAKE_Build_Type").unwrap();
14 assert_eq!(result.0, "");
15 assert_eq!(result.1, Inline::Text("CMAKE_Build_Type".to_string()));
16}
17
18#[test]
19fn test_lowercase_env_var() {
20 let result = environment_variable("my_custom_var").unwrap();
21 assert_eq!(result.0, "");
22 assert_eq!(result.1, Inline::Text("my_custom_var".to_string()));
23}
24
25#[test]
26fn test_env_var_with_numbers() {
27 let result = environment_variable("VAR_123_test").unwrap();
28 assert_eq!(result.0, "");
29 assert_eq!(result.1, Inline::Text("VAR_123_test".to_string()));
30}
31
32#[test]
33fn test_reject_no_underscore() {
34 assert!(environment_variable("NOUNDERCORE").is_err());
35}
36
37#[test]
38fn test_reject_starts_with_underscore() {
39 assert!(environment_variable("_INVALID").is_err());
40}
41
42#[test]
43fn test_reject_ends_with_underscore() {
44 assert!(environment_variable("INVALID_").is_err());
45}
46
47#[test]
48fn test_reject_consecutive_underscores() {
49 assert!(environment_variable("INVALID__VAR").is_err());
50}
51
52#[test]
53fn test_reject_too_short() {
54 assert!(environment_variable("A_").is_err());
55 assert!(environment_variable("_A").is_err());
56}
57
58#[test]
59fn test_integration_with_full_parser() {
60 use crate::parser::parse_markdown;
61
62 let result = parse_markdown("PKG_CONFIG_PATH").unwrap();
63 println!("Integration test result: {result:?}");
64
65 if let Block::Paragraph(inlines) = &result.blocks[0] {
67 assert_eq!(inlines.len(), 1);
68 if let Inline::Text(text) = &inlines[0] {
69 assert_eq!(text, "PKG_CONFIG_PATH");
70 } else {
71 panic!("Expected Text, got {:?}", inlines[0]);
72 }
73 }
74}
75