25 lines
570 B
Factor
25 lines
570 B
Factor
USING: assocs kernel tools.test trees trees.cb trees.private ;
|
|
IN: trees.cb.tests
|
|
|
|
! Insertion into empty tree
|
|
{ T{ cb { root T{ node { key 0 } { value 0 } } } { count 1 } } } [
|
|
0 0 <cb> [ set-at ] keep
|
|
] unit-test
|
|
|
|
! Insertion into a leaf-node resulting in splitting
|
|
{
|
|
T{ cb
|
|
{ root
|
|
T{ cb-node
|
|
{ bits 247 }
|
|
{ left T{ node { key 1 } { value 1 } } }
|
|
{ right T{ node { key 0 } { value 0 } } }
|
|
}
|
|
}
|
|
{ count 2 }
|
|
}
|
|
} [
|
|
0 0 <cb> [ set-at ] keep
|
|
1 1 rot [ set-at ] keep
|
|
] unit-test
|