1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

add variable and method modules

This commit is contained in:
lurchi 2016-09-11 03:11:14 +02:00
parent 27dc1292ba
commit 749d0abf79
10 changed files with 365 additions and 4 deletions

38
rust/tests/test_method.rs Normal file
View file

@ -0,0 +1,38 @@
extern crate psyc;
use psyc::*;
#[test]
fn test_method_matching() {
let m = Method {method: b"_notice_context_enter"};
assert!(m.inherits(b"_notice_context"));
assert!(m.matches(b"_context"));
}
#[test]
fn test_method_lookup() {
let m = Method {method: b"_notice_context_enter"};
let expected_flags = PSYC_METHOD_TEMPLATE |
PSYC_METHOD_VISIBLE |
PSYC_METHOD_LOGGABLE;
assert_eq!(m.lookup(),
MethodInfo {
lookup_result: PsycMethod::PSYC_MC_NOTICE_CONTEXT_ENTER,
family: PsycMethod::PSYC_MC_NOTICE,
flags: expected_flags
});
}
#[test]
fn test_lookup_empty() {
let m = Method {method: b""};
assert_eq!(m.lookup(),
MethodInfo {
lookup_result: PsycMethod::PSYC_MC_UNKNOWN,
family: PsycMethod::PSYC_MC_UNKNOWN,
flags: PsycMethodFlags::empty()
});
}

View file

@ -0,0 +1,44 @@
extern crate psyc;
use psyc::*;
#[test]
fn test_routing_variable() {
let r = RoutingVariable {variable: b"_amount_fragments"};
assert_eq!(r.lookup(), PsycRoutingVar::PSYC_RVAR_AMOUNT_FRAGMENTS);
assert_eq!(r.datatype(), PsycType::PSYC_TYPE_AMOUNT);
assert_eq!(r.is_list(), false);
}
#[test]
fn test_entity_variable() {
let e = EntityVariable {variable: b"_nick_family"};
assert_eq!(e.datatype(), PsycType::PSYC_TYPE_NICK);
assert!(! e.is_list());
}
#[test]
fn test_empty() {
let r = RoutingVariable {variable: b""};
assert_eq!(r.lookup(), PsycRoutingVar::PSYC_RVAR_UNKNOWN);
assert_eq!(r.datatype(), PsycType::PSYC_TYPE_UNKNOWN);
assert!(! r.is_list());
}
#[test]
fn test_inherits() {
let r = RoutingVariable {variable: b"_target_relay"};
assert!(r.inherits(b"_target"));
assert!(! r.inherits(b""));
}
#[test]
fn test_matches() {
let r = RoutingVariable {variable: b"_target_relay"};
assert!(r.matches(b"_relay"));
assert!(! r.matches(b""));
}