v2 / vlib / v / tests / builtin_maps / map_key_alias_test.v
16 lines · 13 sloc · 414 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1type String = string
2type Rune = rune
3
4fn test_map_key_alias() {
5 mut str_data := map[string]map[String]string{}
6 str_data['str'][String('String')] = 'test'
7 assert '${str_data}' == "{'str': {'String': 'test'}}"
8
9 mut i32_data := map[i32]string{}
10 i32_data[23] = 'num'
11 assert '${i32_data}' == "{23: 'num'}"
12
13 mut rune_data := map[Rune]string{}
14 rune_data[`A`] = 'rune'
15 assert '${rune_data}' == "{`A`: 'rune'}"
16}
17