@@ -22,38 +22,14 @@ fn all_test_dmm() -> Vec<std::path::PathBuf> {
22
22
. collect_vec ( )
23
23
}
24
24
25
- #[ test]
26
- fn grid_check ( ) {
27
- let path = std:: path:: Path :: new ( "src/mapmanip/test-in/_tiny_test_map.dmm" ) ;
28
- println ! ( "path: {}" , path. display( ) ) ;
29
-
30
- let grid_map = crate :: mapmanip:: core:: GridMap :: from_file ( & path) . unwrap ( ) ;
31
- assert ! ( grid_map. grid[ & dmm:: Coord2 :: new( 2 , 1 ) ]
32
- . prefabs
33
- . iter( )
34
- . any( |p| p. path == "/obj/random/firstaid" ) ) ;
35
- assert ! ( grid_map. grid[ & dmm:: Coord2 :: new( 1 , 2 ) ]
36
- . prefabs
37
- . iter( )
38
- . any( |p| p. path == "/obj/random/finances" ) ) ;
39
- assert ! ( grid_map. grid[ & dmm:: Coord2 :: new( 14 , 15 ) ]
40
- . prefabs
41
- . iter( )
42
- . any( |p| p. path == "/obj/random/handgun" ) ) ;
43
- assert ! ( grid_map. grid[ & dmm:: Coord2 :: new( 15 , 14 ) ]
44
- . prefabs
45
- . iter( )
46
- . any( |p| p. path == "/obj/random/handgun" ) ) ;
47
- }
48
-
49
25
#[ test]
50
26
fn to_grid_and_back ( ) {
51
27
for path in all_test_dmm ( ) {
52
28
println ! ( "path: {}" , path. display( ) ) ;
53
29
54
30
let dict_map_original = dmmtools:: dmm:: Map :: from_file ( & path) . unwrap ( ) ;
55
31
let grid_map = crate :: mapmanip:: core:: to_grid_map ( & dict_map_original) ;
56
- let dict_map_again = crate :: mapmanip:: core:: to_dict_map ( & grid_map) ;
32
+ let dict_map_again = crate :: mapmanip:: core:: to_dict_map ( & grid_map) . unwrap ( ) ;
57
33
let map_str_original = crate :: mapmanip:: core:: map_to_string ( & dict_map_original) . unwrap ( ) ;
58
34
let map_str_from_grid = crate :: mapmanip:: core:: map_to_string ( & dict_map_again) . unwrap ( ) ;
59
35
@@ -83,10 +59,11 @@ fn extract() {
83
59
& grid_map_src,
84
60
Coord2 :: new ( 4 , 7 ) ,
85
61
Coord2 :: new ( 10 , 5 ) ,
86
- ) ;
62
+ )
63
+ . unwrap ( ) ;
87
64
let grid_map_xtr_expected = crate :: mapmanip:: core:: to_grid_map ( & dict_map_xtr_expected) ;
88
65
89
- let dict_map_xtr = crate :: mapmanip:: core:: to_dict_map ( & grid_map_xtr) ;
66
+ let dict_map_xtr = crate :: mapmanip:: core:: to_dict_map ( & grid_map_xtr) . unwrap ( ) ;
90
67
dict_map_xtr. to_file ( path_xtr_out) . unwrap ( ) ;
91
68
92
69
assert_eq ! (
@@ -95,8 +72,8 @@ fn extract() {
95
72
) ;
96
73
97
74
for key in grid_map_xtr_expected. grid . keys ( ) {
98
- let tile_xtr_expected = grid_map_xtr_expected. grid . get ( key) . unwrap ( ) ;
99
- let tile_xtr = grid_map_xtr. grid . get ( key) . unwrap ( ) ;
75
+ let tile_xtr_expected = grid_map_xtr_expected. grid . get ( & key) . unwrap ( ) ;
76
+ let tile_xtr = grid_map_xtr. grid . get ( & key) . unwrap ( ) ;
100
77
assert_eq ! ( tile_xtr_expected. prefabs, tile_xtr. prefabs) ;
101
78
}
102
79
}
@@ -111,16 +88,17 @@ fn insert() {
111
88
crate :: mapmanip:: core:: GridMap :: from_file ( & path_dst_expected) . unwrap ( ) ;
112
89
let grid_map_xtr = crate :: mapmanip:: core:: GridMap :: from_file ( & path_xtr) . unwrap ( ) ;
113
90
let mut grid_map_dst = crate :: mapmanip:: core:: GridMap :: from_file ( & path_dst) . unwrap ( ) ;
114
- crate :: mapmanip:: tools:: insert_submap ( & grid_map_xtr, Coord2 :: new ( 6 , 4 ) , & mut grid_map_dst) ;
91
+ crate :: mapmanip:: tools:: insert_submap ( & grid_map_xtr, Coord2 :: new ( 6 , 4 ) , & mut grid_map_dst)
92
+ . unwrap ( ) ;
115
93
116
94
assert_eq ! (
117
95
grid_map_dst_expected. grid. keys( ) . collect:: <Vec <_>>( ) ,
118
96
grid_map_dst. grid. keys( ) . collect:: <Vec <_>>( ) ,
119
97
) ;
120
98
121
99
for key in grid_map_dst_expected. grid . keys ( ) {
122
- let tile_dst_expected = grid_map_dst_expected. grid . get ( key) . unwrap ( ) ;
123
- let tile_dst = grid_map_dst. grid . get ( key) . unwrap ( ) ;
100
+ let tile_dst_expected = grid_map_dst_expected. grid . get ( & key) . unwrap ( ) ;
101
+ let tile_dst = grid_map_dst. grid . get ( & key) . unwrap ( ) ;
124
102
assert_eq ! ( tile_dst_expected. prefabs, tile_dst. prefabs) ;
125
103
}
126
104
}
@@ -138,12 +116,12 @@ fn keys_deduplicated() {
138
116
for tile in grid_map_out. grid . values_mut ( ) {
139
117
tile. key_suggestion = dmm:: Key :: default ( ) ;
140
118
}
141
- let dict_map_out = crate :: mapmanip:: core:: to_dict_map ( & grid_map_out) ;
119
+ let dict_map_out = crate :: mapmanip:: core:: to_dict_map ( & grid_map_out) . unwrap ( ) ;
142
120
let grid_map_out = crate :: mapmanip:: core:: to_grid_map ( & dict_map_out) ;
143
121
144
122
for key in grid_map_src. grid . keys ( ) {
145
- let tile_src = grid_map_src. grid . get ( key) . unwrap ( ) ;
146
- let tile_out = grid_map_out. grid . get ( key) . unwrap ( ) ;
123
+ let tile_src = grid_map_src. grid . get ( & key) . unwrap ( ) ;
124
+ let tile_out = grid_map_out. grid . get ( & key) . unwrap ( ) ;
147
125
assert_eq ! ( tile_src. prefabs, tile_out. prefabs) ;
148
126
}
149
127
@@ -152,14 +130,15 @@ fn keys_deduplicated() {
152
130
153
131
#[ test]
154
132
fn mapmanip_configs_parse ( ) {
155
- let foo = vec ! [ crate :: mapmanip:: MapManipulation :: InsertExtract {
133
+ let foo = vec ! [ crate :: mapmanip:: MapManipulation :: SubmapExtractInsert {
156
134
submap_size_x: 1 ,
157
135
submap_size_y: 2 ,
158
136
submaps_dmm: "a" . to_owned( ) ,
159
137
marker_extract: "b" . to_owned( ) ,
160
138
marker_insert: "c" . to_owned( ) ,
139
+ submaps_can_repeat: true ,
161
140
} ] ;
162
- dbg ! ( serde_json:: to_string( & foo) ) ;
141
+ dbg ! ( serde_json:: to_string( & foo) . unwrap ( ) ) ;
163
142
164
143
let mapmanip_configs = walkdir:: WalkDir :: new ( "../../maps" )
165
144
. into_iter ( )
@@ -172,3 +151,10 @@ fn mapmanip_configs_parse() {
172
151
let _ = crate :: mapmanip:: mapmanip_config_parse ( & config) ;
173
152
}
174
153
}
154
+
155
+ #[ test]
156
+ fn mapmanip_configs_execute ( ) {
157
+ // this is only "unsafe" cause that function is `extern "C"`
158
+ // it does not do anything actually unsafe
159
+ unsafe { crate :: all_mapmanip_configs_execute_ffi ( ) }
160
+ }
0 commit comments