Buttplug sex toy control library
at master 64 lines 1.7 kB view raw
1use buttplug_server_device_config::{UserDeviceIdentifier, load_protocol_configs}; 2use test_case::test_case; 3 4#[test_case("version_only.json" ; "Version Only")] 5#[test_case("base_aneros_protocol.json" ; "Aneros Protocol")] 6#[test_case("base_tcode_protocol.json" ; "TCode Protocol")] 7fn test_valid_base_config(test_file: &str) { 8 load_protocol_configs( 9 &Some( 10 str::from_utf8(&std::fs::read(format!("tests/test_configs/{}", test_file)).unwrap()) 11 .unwrap() 12 .to_owned(), 13 ), 14 &None, 15 false, 16 ) 17 .unwrap() 18 .finish() 19 .unwrap(); 20} 21 22#[test_case("base_tcode_protocol.json", "user_tcode_protocol.json" ; "TCode Protocol")] 23fn test_valid_user_config(base_config: &str, user_config: &str) { 24 load_protocol_configs( 25 &Some( 26 str::from_utf8(&std::fs::read(format!("tests/test_configs/{}", base_config)).unwrap()) 27 .unwrap() 28 .to_owned(), 29 ), 30 &Some( 31 str::from_utf8(&std::fs::read(format!("tests/test_configs/{}", user_config)).unwrap()) 32 .unwrap() 33 .to_owned(), 34 ), 35 false, 36 ) 37 .unwrap() 38 .finish() 39 .unwrap(); 40} 41 42#[test] 43fn test_tcode_device_creation() { 44 let dcm = load_protocol_configs( 45 &Some( 46 str::from_utf8(&std::fs::read("tests/test_configs/base_tcode_protocol.json").unwrap()) 47 .unwrap() 48 .to_owned(), 49 ), 50 &Some( 51 str::from_utf8(&std::fs::read("tests/test_configs/user_tcode_protocol.json").unwrap()) 52 .unwrap() 53 .to_owned(), 54 ), 55 false, 56 ) 57 .unwrap() 58 .finish() 59 .unwrap(); 60 let device = dcm 61 .device_definition(&UserDeviceIdentifier::new("COM1", "tcode-v03", &None)) 62 .unwrap(); 63 assert_eq!(device.name(), "TCode v0.3 (Single Linear Axis)"); 64}