# Test semantics of batched updates that partially overlap with what's already
# present, possibly straddling multiple existing entries.

# keys    a  b  c  d  e  f  g  h  i  j
# state
# set        [--A--)  [--B--)
# ====================================
# result     [--A--)  [--B--)
apply
set [b,d):A
set [e,g):B
----
added [b,d):A
added [e,g):B

# We will need to get back to the current state in this test.
checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set           [---X----)
# ====================================
# result     [-A|----X---|-B)
apply
set [c,f):X
----
deleted [b,d)
deleted [e,g)
added [b,c):A
added [c,f):X
added [f,g):B

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set           [---X-------)
# ====================================
# result     [-A|----X------)
apply
set [c,g):X
----
deleted [b,d)
deleted [e,g)
added [b,c):A
added [c,g):X

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set           [---X----|xx)
# ====================================
# result     [-A|----X---)
apply
set [c,f):X
delete [f,g)
----
deleted [b,d)
deleted [e,g)
added [b,c):A
added [c,f):X

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set           [---X----------)
# ====================================
# result     [-A|----X---------)
apply
set [c,h):X
----
deleted [b,d)
deleted [e,g)
added [b,c):A
added [c,h):X

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set        [---X-------)
# ====================================
# result     [-------X---|-B)
apply
set [b,f):X
----
deleted [b,d)
deleted [e,g)
added [b,f):X
added [f,g):B

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set     [------X-------)
# ====================================
# result  [----------X---|-B)
apply
set [a,f):X
----
deleted [b,d)
deleted [e,g)
added [a,f):X
added [f,g):B

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set           [xxxxxxxx)
# ====================================
# result     [-A)        [-B)
apply
delete [c,f)
----
deleted [b,d)
deleted [e,g)
added [b,c):A
added [f,g):B

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set     [xxxxx|---X----------)
# ====================================
# result        [----X---------)
apply
delete [a,c)
set [c,h):X
----
deleted [b,d)
deleted [e,g)
added [c,h):X

restore-checkpoint
----

# keys    a  b  c  d  e  f  g  h  i  j
# state      [--A--)  [--B--)
# set        [--X--|xxxxx|-Y)
# ====================================
# result     [--X--)     [-Y)
apply
set [b,d):X
delete [d,f)
set [f,g):Y
----
deleted [b,d)
deleted [e,g)
added [b,d):X
added [f,g):Y
