testMapSetMapSet :: TestTree
testMapSetMapSet =
  let ms1 = O.MapSet "foo" c 0
      ms2 = O.MapSet "foo" c2 1
      ms3 = O.MapSet "bar" c 0
      ms4 = O.MapSet "foo" c 1 in
  testGroup "MapSet vs MapSet"
  [ testCase "Non-conflicting" $ do
      assertEqual "a" (Just ms1) $ T.transform ms1 ms3 T.Left
      assertEqual "b" (Just ms1) $ T.transform ms1 ms3 T.Right
  , testCase "Wins tiebreaker" $ do
      assertEqual "a" (Just ms2) $ T.transform ms2 ms1 T.Left
      assertEqual "b" (Just ms2) $ T.transform ms2 ms1 T.Right
      assertEqual "c" (Just ms2) $ T.transform ms2 ms4 T.Right
  , testCase "Loses tiebreaker" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms2 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms2 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms2 ms4 T.Left
  , testCase "Equal objects" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms4 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms4 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms4 ms1 T.Left
      assertEqual "d" (Just O.NoOp) $ T.transform ms4 ms1 T.Right
  ]
testMapSetMapSet :: TestTree
testMapSetMapSet =
  let ms1 = O.MapSet "foo" c 0
      ms2 = O.MapSet "foo" c2 1
      ms3 = O.MapSet "bar" c 0
      ms4 = O.MapSet "foo" c 1 in
  testGroup "MapSet vs MapSet"
  [ testCase "Non-conflicting" $ do
      assertEqual "a" (Just ms1) $ T.transform ms1 ms3 T.Left
      assertEqual "b" (Just ms1) $ T.transform ms1 ms3 T.Right
  , testCase "Wins tiebreaker" $ do
      assertEqual "a" (Just ms2) $ T.transform ms2 ms1 T.Left
      assertEqual "b" (Just ms2) $ T.transform ms2 ms1 T.Right
      assertEqual "c" (Just ms2) $ T.transform ms2 ms4 T.Right
  , testCase "Loses tiebreaker" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms2 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms2 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms2 ms4 T.Left
  , testCase "Equal objects" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms4 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms4 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms4 ms1 T.Left
      assertEqual "d" (Just O.NoOp) $ T.transform ms4 ms1 T.Right
  ]
testMapSetMapSet =
  let ms1 = O.MapSet "foo" c 0
      ms2 = O.MapSet "foo" c2 1
      ms3 = O.MapSet "bar" c 0
      ms4 = O.MapSet "foo" c 1 in
  testGroup "MapSet vs MapSet"
  [ testCase "Non-conflicting" $ do
      assertEqual "a" (Just ms1) $ T.transform ms1 ms3 T.Left
      assertEqual "b" (Just ms1) $ T.transform ms1 ms3 T.Right
  , testCase "Wins tiebreaker" $ do
      assertEqual "a" (Just ms2) $ T.transform ms2 ms1 T.Left
      assertEqual "b" (Just ms2) $ T.transform ms2 ms1 T.Right
      assertEqual "c" (Just ms2) $ T.transform ms2 ms4 T.Right
  , testCase "Loses tiebreaker" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms2 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms2 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms2 ms4 T.Left
  , testCase "Equal objects" $ do
      assertEqual "a" (Just O.NoOp) $ T.transform ms1 ms4 T.Left
      assertEqual "b" (Just O.NoOp) $ T.transform ms1 ms4 T.Right
      assertEqual "c" (Just O.NoOp) $ T.transform ms4 ms1 T.Left
      assertEqual "d" (Just O.NoOp) $ T.transform ms4 ms1 T.Right
  ]