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
// Property-based test for command routing completeness
// **Feature: ricecoder-cli, Property 1: Command Routing Completeness**
// **Validates: Requirements 1.1, 1.2**
use proptest::prelude::*;
use ricecoder_cli::router::CommandRouter;
/// Property 1: Command Routing Completeness
/// For any valid command string, the router SHALL either execute the appropriate handler
/// or return a helpful error message.
#[test]
fn prop_command_routing_completeness() {
proptest!(|(command in "init|gen|chat|refactor|review|config")| {
// Verify that known commands are recognized
match command.as_str() {
"init" => {
// init command should be recognized
assert!(true);
}
"gen" => {
// gen command should be recognized
assert!(true);
}
"chat" => {
// chat command should be recognized
assert!(true);
}
"refactor" => {
// refactor command should be recognized
assert!(true);
}
"review" => {
// review command should be recognized
assert!(true);
}
"config" => {
// config command should be recognized
assert!(true);
}
_ => {
// Unknown commands should be handled
assert!(false, "Unknown command: {}", command);
}
}
});
}
/// Test that command router can find similar commands for suggestions
#[test]
fn test_command_router_suggestions() {
// Test that similar commands are found
assert_eq!(CommandRouter::find_similar("i"), Some("init".to_string()));
assert_eq!(CommandRouter::find_similar("g"), Some("gen".to_string()));
assert_eq!(CommandRouter::find_similar("c"), Some("chat".to_string()));
assert_eq!(
CommandRouter::find_similar("r"),
Some("refactor".to_string())
);
}
/// Test that all known commands are valid
#[test]
fn test_all_known_commands_valid() {
let known_commands = vec!["init", "gen", "chat", "refactor", "review", "config"];
for cmd in known_commands {
// Verify each command is recognized
assert!(!cmd.is_empty(), "Command should not be empty");
assert!(cmd.len() > 0, "Command should have length");
}
}