Skip to content

Commit

Permalink
Fixing the tests module (hopefully!)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacekookie committed Oct 30, 2017
1 parent 51910f6 commit d8c785c
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 14 deletions.
76 changes: 68 additions & 8 deletions src/tests/clauses.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,78 @@
//! A module that tests everything to dow with clauses
#![allow(unused)]

// #[test]
use terms::*;
use clause::*;

#[test]
fn create() {
assert!(true == true);
let c1 = clause![term!["A"]];
let c2 = clause![term!["A"]];
assert_eq!(c1, c2);
}


// #[test]
#[test]
fn compare() {
// let a = term!["A", "B"];
// let b = term!["B", "C"];
// let c = term!["A", "B"];
let c1 = clause![term!["A"]];
let c2 = clause![term!["A"]];
assert_eq!(c1, c2);

let c3 = clause![term!["A", "B"], term!["!B"]];
let c4 = clause![term!["B", "A"], term!["!B"]];
assert_eq!(c3, c4);

let c5 = clause![term!["A", "B"], term!["B"]];
let c6 = clause![term!["A"], term!["!B"]];
assert!(c5 != c6);
}

#[test]
fn reduce_1() {
let a = term!["A", "!B"];
let b = term!["C", "!D"];
let c = term!["E"];

let mut cl = clause![a, b, c];
cl.reduce();

/* We should no longer contain "E" */
assert!(! cl.contains(&term!["E"]));
}

#[test]
fn reduce_2() {
let a = term!["A", "!B"];
let b = term!["C", "!D"];
let c = term!["E"];
let d = term!["F"];

let mut cl = clause![a.clone(), b.clone(), c, d];
cl.reduce();
cl.reduce();

/* Should now look like {A, !B} & {C, !D} */
assert_eq!(cl, clause![a, b]);
}


#[test]
fn count_symbols() {
let cl = clause![ term!["A", "B"],
term!["A", "!C"],
term!["C"],
term!["B"],
term!["A"]
];

// let clause = clause![a, b];
// unimplemented!();
let count = cl.count_symbols();
let a: i32 = *count.get(&symbol!["A"]).unwrap();
let b: i32 = *count.get(&symbol!["B"]).unwrap();
let c: i32 = *count.get(&symbol!["C"]).unwrap();
let nc: i32 = *count.get(&symbol!["!C"]).unwrap();

assert_eq!(a, 3);
assert_eq!(b, 2);
assert_eq!(c, 1);
assert_eq!(nc, 1);
}
24 changes: 20 additions & 4 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//!
//! If you find sections that need more testing or where test code is not
//! understandable, please don't shy away from creating a new module
//!
//!
//!
//!
//! Here is also a little guide how to write new unit tests for LRS. Generally
//! test cases should rely on as little external code as possible. A test case
//! should create it's own data, work on it and then assert success or failure.
Expand All @@ -24,8 +24,24 @@
//! philosophy should be used.
//!
//! For any further questions about testing, don't hesitate to contact me

#![allow(unused)]

mod symbols;
mod terms;
mod clauses;
mod clauses;

use terms::*;
use clause::*;
use result::*;


/// A small function which tests result creation
#[test]
fn result_create() {
let r = result![true, ("A", false), ("B", true)];
assert_eq!(r.symbols.get(&symbol!["A"]).unwrap(), &false);
assert_eq!(r.symbols.get(&symbol!["B"]).unwrap(), &true);
assert_eq!(r.solvable, true);

println!("{:?}", r);
}
2 changes: 1 addition & 1 deletion src/tests/symbols.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! A module that handles unit testing for symbols
#[allow(unused)]
#![allow(unused)]

use terms::*;

Expand Down
2 changes: 1 addition & 1 deletion src/tests/terms.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! A module that handles unit testing for terms
#[allow(unused)]
#![allow(unused)]

use terms::*;

Expand Down

0 comments on commit d8c785c

Please sign in to comment.