blob: 4d7dd3e40821dddde81b38604d4abf53cef7cd92 [file] [log] [blame]
Jens Geyer5cf9d772015-07-02 21:01:52 +02001%%
2%% Licensed to the Apache Software Foundation (ASF) under one
3%% or more contributor license agreements. See the NOTICE file
4%% distributed with this work for additional information
5%% regarding copyright ownership. The ASF licenses this file
6%% to you under the Apache License, Version 2.0 (the
7%% "License"); you may not use this file except in compliance
8%% with the License. You may obtain a copy of the License at
9%%
10%% http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing,
13%% software distributed under the License is distributed on an
14%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15%% KIND, either express or implied. See the License for the
16%% specific language governing permissions and limitations
17%% under the License.
18%%
19
20-module(test_thrift_3214).
Jens Geyer5cf9d772015-07-02 21:01:52 +020021
22-include("gen-erl/thrift3214_types.hrl").
23
24-ifdef(TEST).
25-include_lib("eunit/include/eunit.hrl").
26
27record_generation_test_() ->
Sergei Elin45764092022-09-23 23:21:31 +030028 [
29 {"StringMap record",
30 ?_assertMatch(
31 {'StringMap', _},
32 #'StringMap'{data = #{50 => "foo"}}
33 )},
34 {"StringMap record defaults",
35 ?_assertEqual(
36 {'StringMap', #{1 => "a", 2 => "b"}},
37 #'StringMap'{}
38 )},
39 {"StringMap record dict from list",
40 ?_assertNotEqual(
41 {'StringMap', dict:from_list([{1, "a"}, {2, "b"}])},
42 #'StringMap'{}
43 )},
44 {"StringMap record map from list",
45 ?_assertEqual(
46 {'StringMap', maps:from_list([{1, "a"}, {2, "b"}])},
47 #'StringMap'{}
48 )}
49 ].
Jens Geyer5cf9d772015-07-02 21:01:52 +020050
51struct_info_test_() ->
Sergei Elin45764092022-09-23 23:21:31 +030052 [
53 {"StringMap extended definition",
54 ?_assertEqual(
55 {struct, [
56 {1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}}
57 ]},
58 thrift3214_types:struct_info_ext('StringMap')
59 )}
60 ].
Jens Geyer5cf9d772015-07-02 21:01:52 +020061
62-endif.