MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / test_array_read

Function test_array_read

battlecode-engine/src/team_array.rs:117–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115
116 #[test]
117 fn test_array_read() {
118 let team_arrays = TeamArrayInfo::new();
119 let earth_arrays = team_arrays.filter(Planet::Earth);
120 let mars_arrays = team_arrays.filter(Planet::Mars);
121 let arrays = vec![team_arrays, earth_arrays, mars_arrays];
122
123 for arr in arrays {
124 let earth_first = arr.first_array(Planet::Earth);
125 let earth_last = arr.last_array(Planet::Earth);
126 let mars_first = arr.first_array(Planet::Mars);
127 let mars_last = arr.last_array(Planet::Mars);
128
129 // All arrays are the right length.
130 assert_eq!(earth_first.len(), COMMUNICATION_ARRAY_LENGTH);
131 assert_eq!(earth_last.len(), COMMUNICATION_ARRAY_LENGTH);
132 assert_eq!(mars_first.len(), COMMUNICATION_ARRAY_LENGTH);
133 assert_eq!(mars_last.len(), COMMUNICATION_ARRAY_LENGTH);
134
135 // Both planet arrays are initialized with all 0's.
136 for index in 0..COMMUNICATION_ARRAY_LENGTH {
137 assert_eq!(earth_first[index], 0);
138 assert_eq!(earth_last[index], 0);
139 assert_eq!(mars_first[index], 0);
140 assert_eq!(mars_last[index], 0);
141 }
142 }
143 }
144
145 #[test]
146 fn test_array_write() {

Callers

nothing calls this directly

Calls 3

first_arrayMethod · 0.80
last_arrayMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected