forked from mirrors/jj
tests: start using the maplit crate
This commit is contained in:
parent
c41251eaff
commit
88e7f4a30c
4 changed files with 45 additions and 35 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -514,6 +514,7 @@ dependencies = [
|
|||
"dirs",
|
||||
"git2",
|
||||
"hex",
|
||||
"maplit",
|
||||
"protobuf",
|
||||
"protobuf-codegen-pure",
|
||||
"protos",
|
||||
|
|
|
@ -20,6 +20,7 @@ diff = "0.1"
|
|||
dirs = "2.0"
|
||||
git2 = "0.13"
|
||||
hex = "0.4"
|
||||
maplit = "1.0.2"
|
||||
protobuf = { version = "2.12", features = ["with-bytes"] }
|
||||
protobuf-codegen-pure = "2.12"
|
||||
rand = "0.7.3"
|
||||
|
|
|
@ -298,7 +298,6 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
fn topo_order_reverse_linear() {
|
||||
|
@ -307,10 +306,11 @@ mod tests {
|
|||
// o B
|
||||
// o A
|
||||
|
||||
let mut neighbors = HashMap::new();
|
||||
neighbors.insert('A', vec![]);
|
||||
neighbors.insert('B', vec!['A']);
|
||||
neighbors.insert('C', vec!['B']);
|
||||
let neighbors = hashmap! {
|
||||
'A' => vec![],
|
||||
'B' => vec!['A'],
|
||||
'C' => vec!['B'],
|
||||
};
|
||||
|
||||
let common = topo_order_reverse(
|
||||
vec!['C'],
|
||||
|
@ -333,13 +333,14 @@ mod tests {
|
|||
// |/
|
||||
// o A
|
||||
|
||||
let mut neighbors = HashMap::new();
|
||||
neighbors.insert('A', vec![]);
|
||||
neighbors.insert('B', vec!['A']);
|
||||
neighbors.insert('C', vec!['B']);
|
||||
neighbors.insert('D', vec!['C']);
|
||||
neighbors.insert('E', vec!['A']);
|
||||
neighbors.insert('F', vec!['E', 'D']);
|
||||
let neighbors = hashmap! {
|
||||
'A' => vec![],
|
||||
'B' => vec!['A'],
|
||||
'C' => vec!['B'],
|
||||
'D' => vec!['C'],
|
||||
'E' => vec!['A'],
|
||||
'F' => vec!['E', 'D'],
|
||||
};
|
||||
|
||||
let common = topo_order_reverse(
|
||||
vec!['F'],
|
||||
|
@ -364,13 +365,14 @@ mod tests {
|
|||
// |/
|
||||
// o A
|
||||
|
||||
let mut neighbors = HashMap::new();
|
||||
neighbors.insert('A', vec![]);
|
||||
neighbors.insert('B', vec!['A']);
|
||||
neighbors.insert('C', vec!['B']);
|
||||
neighbors.insert('D', vec!['A']);
|
||||
neighbors.insert('E', vec!['A']);
|
||||
neighbors.insert('F', vec!['E', 'D']);
|
||||
let neighbors = hashmap! {
|
||||
'A' => vec![],
|
||||
'B' => vec!['A'],
|
||||
'C' => vec!['B'],
|
||||
'D' => vec!['A'],
|
||||
'E' => vec!['A'],
|
||||
'F' => vec!['E', 'D'],
|
||||
};
|
||||
|
||||
let common = topo_order_reverse(
|
||||
vec!['F', 'C'],
|
||||
|
@ -396,15 +398,16 @@ mod tests {
|
|||
// \|/
|
||||
// A
|
||||
|
||||
let mut neighbors = HashMap::new();
|
||||
neighbors.insert('A', vec![]);
|
||||
neighbors.insert('B', vec!['A']);
|
||||
neighbors.insert('C', vec!['B']);
|
||||
neighbors.insert('D', vec!['C']);
|
||||
neighbors.insert('E', vec!['A', 'D']);
|
||||
neighbors.insert('F', vec!['B']);
|
||||
neighbors.insert('G', vec!['F']);
|
||||
neighbors.insert('H', vec!['A', 'G']);
|
||||
let neighbors = hashmap! {
|
||||
'A' => vec![],
|
||||
'B' => vec!['A'],
|
||||
'C' => vec!['B'],
|
||||
'D' => vec!['C'],
|
||||
'E' => vec!['A','D'],
|
||||
'F' => vec!['B'],
|
||||
'G' => vec!['F'],
|
||||
'H' => vec!['A', 'G'],
|
||||
};
|
||||
|
||||
let common = closest_common_node(
|
||||
vec!['E'],
|
||||
|
@ -429,13 +432,14 @@ mod tests {
|
|||
// |
|
||||
// A
|
||||
|
||||
let mut neighbors = HashMap::new();
|
||||
neighbors.insert('A', vec![]);
|
||||
neighbors.insert('b', vec!['A']);
|
||||
neighbors.insert('C', vec!['b']);
|
||||
neighbors.insert('D', vec!['C']);
|
||||
neighbors.insert('e', vec!['b']);
|
||||
neighbors.insert('F', vec!['C', 'e']);
|
||||
let neighbors = hashmap! {
|
||||
'A' => vec![],
|
||||
'b' => vec!['A'],
|
||||
'C' => vec!['b'],
|
||||
'D' => vec!['C'],
|
||||
'e' => vec!['b'],
|
||||
'F' => vec!['C', 'e'],
|
||||
};
|
||||
let expected: HashSet<char> = vec!['D', 'F'].into_iter().collect();
|
||||
|
||||
let actual = unreachable(
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
#![feature(get_mut_unchecked)]
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate maplit;
|
||||
|
||||
pub mod commit;
|
||||
pub mod commit_builder;
|
||||
pub mod conflicts;
|
||||
|
|
Loading…
Reference in a new issue