| 1 | fn test_complex_map_op1() { |
| 2 | mut test_map := map[string]Point_map{} |
| 3 | |
| 4 | test_map['test1'] = Point_map{ |
| 5 | points: { |
| 6 | 'point3': []Point{} |
| 7 | } |
| 8 | } |
| 9 | test_map['test2'] = Point_map{ |
| 10 | points: { |
| 11 | 'point4': []Point{} |
| 12 | } |
| 13 | } |
| 14 | test_map['test1'].points['point3'] << Point{10, 20} |
| 15 | test_map['test2'].points['point4'] << Point{50, 60} |
| 16 | |
| 17 | println(test_map) |
| 18 | |
| 19 | assert test_map.len == 2 |
| 20 | assert Point{10, 20} in test_map['test1'].points['point3'] |
| 21 | assert Point{50, 60} in test_map['test2'].points['point4'] |
| 22 | assert Point{10, 20} !in test_map['test2'].points['point4'] |
| 23 | assert Point{1, 2} !in test_map['test1'].points['point3'] |
| 24 | } |
| 25 | |
| 26 | fn test_complex_map_op2() { |
| 27 | mut test_map := map[string]map[string][]Point{} |
| 28 | |
| 29 | test_map['test1'] = { |
| 30 | 'point3': []Point{} |
| 31 | } |
| 32 | test_map['test2'] = { |
| 33 | 'point4': []Point{} |
| 34 | } |
| 35 | test_map['test1']['point3'] << Point{10, 20} |
| 36 | test_map['test2']['point4'] << Point{50, 60} |
| 37 | |
| 38 | println(test_map) |
| 39 | |
| 40 | assert test_map.len == 2 |
| 41 | assert Point{10, 20} in test_map['test1']['point3'] |
| 42 | assert Point{50, 60} in test_map['test2']['point4'] |
| 43 | assert Point{10, 20} !in test_map['test2']['point4'] |
| 44 | assert Point{1, 2} !in test_map['test1']['point3'] |
| 45 | } |
| 46 | |
| 47 | struct Point { |
| 48 | mut: |
| 49 | x int |
| 50 | y int |
| 51 | } |
| 52 | |
| 53 | struct Point_map { |
| 54 | mut: |
| 55 | points map[string][]Point |
| 56 | } |
| 57 | |