-
Notifications
You must be signed in to change notification settings - Fork 4
/
general.rs
65 lines (51 loc) · 1.93 KB
/
general.rs
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
#![allow(clippy::restriction)]
#![allow(clippy::unnecessary_cast)]
use libpd_rs::functions::{
add_to_search_paths, block_size, clear_search_paths, close_patch, get_dollar_zero, init,
initialize_audio, open_patch, verbose_print_state, verbose_print_state_active,
};
use libpd_rs::types::PatchFileHandle;
#[test]
fn all_main_functionality() {
let result = init();
assert!(result.is_ok());
let result = init();
assert!(result.is_ok());
let result = initialize_audio(0, 2, 44100);
assert!(result.is_ok());
let result = initialize_audio(0, 1, 44100);
assert!(result.is_ok());
let result = open_patch("tests/patches/no_eresultistent.pd");
assert!(result.is_err());
let result = open_patch("/bad_path");
assert!(result.is_err());
let result = open_patch("tests/patches/simple.pd");
assert!(result.is_ok());
let result = close_patch(result.unwrap());
assert!(result.is_ok());
let handle: PatchFileHandle = (std::ptr::null_mut() as *mut std::ffi::c_void).into();
let result = close_patch(handle);
assert!(result.is_err());
let result = add_to_search_paths("tests/patches");
assert!(result.is_ok());
let result = add_to_search_paths("/bad_path");
assert!(result.is_err());
clear_search_paths();
let patch_handle = open_patch("tests/patches/simple.pd").unwrap();
let result = get_dollar_zero(&patch_handle);
assert!(result.is_ok());
assert_ne!(result.unwrap(), 0);
let handle: PatchFileHandle = (std::ptr::null_mut() as *mut std::ffi::c_void).into();
let result = get_dollar_zero(&handle);
assert!(result.is_err());
let result = block_size();
assert_eq!(result, 64);
let result = verbose_print_state_active();
assert!(!result);
verbose_print_state(true);
let result = verbose_print_state_active();
assert!(result);
verbose_print_state(false);
let result = verbose_print_state_active();
assert!(!result);
}