anchor.diff:                    end,
                     Alts).
   
  +nif_encode_decode_maps() ->
  +    with_tmpdir(
  +      fun(TmpDir) ->
  +              NEDM = gpb_nif_test_ed_mapfields1,
  +              Defs = mk_one_map_field_of_each_type(),
  +              {ok, Code} = compile_nif_msg_defs(NEDM, Defs, TmpDir),
  +              in_separate_vm(
  +                TmpDir, NEDM, Code,
  +                fun() ->
  +                        nif_encode_decode_mapfields(NEDM, Defs),
  +                        ok
  +                end)
  +      end).
  +
  +nif_encode_decode_mapfields(NEDM, Defs) ->
  +    OrigMsg = usort_all_fields(mk_msg(map1, Defs, small_random)),
  +    %% cross-check with gpb:encode/decode_msg to avoid errors cancelling out
  +    MEncoded  = NEDM:encode_msg(OrigMsg),
  +    GEncoded  = gpb:encode_msg(OrigMsg, Defs),
  +    MMDecoded = NEDM:decode_msg(MEncoded, map1),
  +    GMDecoded = gpb:decode_msg(MEncoded, map1, Defs),
  +    MGDecoded = NEDM:decode_msg(GEncoded, map1),
  +    ?assertEqual(OrigMsg, sort_all_fields(MMDecoded)),
  +    ?assertEqual(OrigMsg, sort_all_fields(GMDecoded)),
  +    ?assertEqual(OrigMsg, sort_all_fields(MGDecoded)).
  +
  +usort_all_fields(R) -> map_all_fields(R, fun list:usort/1).
  +
  +sort_all_fields(R) -> map_all_fields(R, fun list:sort/1).
  +
  +map_all_fields(R, Fn) ->
  +    [RName | Fields] = tuple_to_list(R),
  +    list_to_tuple([RName | [Fn(Field) || Field <- Fields]]).
   
   nif_enum_in_msg() ->
       with_tmpdir(
  
positive.code:             CanIt
      end.
  
  find_protoc_version() ->
      Output = os:cmd(find_protoc() ++ " --version"),
      find_protoc_version_aux(string:tokens(Output, " \t\r\n"), Output).
  
negative.code:     nif_tests_check_prerequisites(
        [{"Nif compiles", fun nif_compiles/0},
         {"Nif encode decode", fun nif_encode_decode/0},
         nif_encode_decode_maps_(),
         {"Nif enums in msgs", fun nif_enum_in_msg/0},
         {"Nif enums with pkgs", fun nif_enum_with_pkgs/0},
         {"Nif with strbin", fun nif_with_strbin/0}]).
  