blob: 118e77944d98cdd2de0f8e5c973ba231c1265298 [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).
21-compile(export_all).
22
23-include("gen-erl/thrift3214_types.hrl").
24
25-ifdef(TEST).
26-include_lib("eunit/include/eunit.hrl").
27
28record_generation_test_() ->
29 [
30 {"StringMap record", ?_assertMatch(
31 {'StringMap', _},
32 #'StringMap'{data=#{50 => "foo"}}
33 )},
34 {"StringMap record defaults", ?_assertEqual(
35 {'StringMap', #{1 => "a", 2 => "b"}},
36 #'StringMap'{}
37 )},
38 {"StringMap record dict from list", ?_assertNotEqual(
39 {'StringMap', dict:from_list([{1, "a"}, {2, "b"}])},
40 #'StringMap'{}
41 )},
42 {"StringMap record map from list", ?_assertEqual(
43 {'StringMap', maps:from_list([{1, "a"}, {2, "b"}])},
44 #'StringMap'{}
45 )}
46 ].
47
48struct_info_test_() ->
49 [
50 {"StringMap extended definition", ?_assertEqual(
51 {struct, [
52 {1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}}
53 ]},
54 thrift3214_types:struct_info_ext('StringMap')
55 )}
56 ].
57
58-endif.