Skip to content

Commit a23fb2c

Browse files
committed
Add some tests for section offsets to ensure we don't break those going forward.
1 parent d55a667 commit a23fb2c

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

broodrep/src/lib.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,83 @@ mod tests {
965965
let observers = replay.header.observers().collect::<Vec<_>>();
966966
assert_eq!(observers.len(), 0);
967967
}
968+
969+
#[test]
970+
fn replay_sections_legacy() {
971+
let mut cursor = Cursor::new(LEGACY);
972+
let replay = Replay::new(&mut cursor).unwrap();
973+
974+
assert_eq!(
975+
replay.section_offsets.get(&ReplaySection::Header),
976+
Some(&16)
977+
);
978+
assert_eq!(
979+
replay.section_offsets.get(&ReplaySection::Commands),
980+
Some(&227)
981+
);
982+
assert_eq!(
983+
replay.section_offsets.get(&ReplaySection::MapData),
984+
Some(&482)
985+
);
986+
assert_eq!(
987+
replay.section_offsets.get(&ReplaySection::PlayerNames),
988+
Some(&74769)
989+
);
990+
assert_eq!(replay.section_offsets.get(&ReplaySection::Skins), None);
991+
assert_eq!(replay.section_offsets.get(&ReplaySection::Limits), None);
992+
assert_eq!(replay.section_offsets.get(&ReplaySection::Bfix), None);
993+
assert_eq!(
994+
replay.section_offsets.get(&ReplaySection::CustomColors),
995+
None
996+
);
997+
assert_eq!(replay.section_offsets.get(&ReplaySection::Gcfg), None);
998+
assert_eq!(
999+
replay.section_offsets.get(&ReplaySection::ShieldBattery),
1000+
None
1001+
);
1002+
}
1003+
1004+
#[test]
1005+
fn replay_sections_scr_121() {
1006+
let mut cursor = Cursor::new(SCR_121);
1007+
let replay = Replay::new(&mut cursor).unwrap();
1008+
1009+
assert_eq!(
1010+
replay.section_offsets.get(&ReplaySection::Header),
1011+
Some(&20)
1012+
);
1013+
assert_eq!(
1014+
replay.section_offsets.get(&ReplaySection::Commands),
1015+
Some(&225)
1016+
);
1017+
assert_eq!(
1018+
replay.section_offsets.get(&ReplaySection::MapData),
1019+
Some(&288)
1020+
);
1021+
assert_eq!(
1022+
replay.section_offsets.get(&ReplaySection::PlayerNames),
1023+
Some(&44123)
1024+
);
1025+
assert_eq!(
1026+
replay.section_offsets.get(&ReplaySection::Skins),
1027+
Some(&44222)
1028+
);
1029+
assert_eq!(
1030+
replay.section_offsets.get(&ReplaySection::Limits),
1031+
Some(&44282)
1032+
);
1033+
assert_eq!(
1034+
replay.section_offsets.get(&ReplaySection::Bfix),
1035+
Some(&44330)
1036+
);
1037+
assert_eq!(
1038+
replay.section_offsets.get(&ReplaySection::CustomColors),
1039+
Some(&44358)
1040+
);
1041+
assert_eq!(replay.section_offsets.get(&ReplaySection::Gcfg), None);
1042+
assert_eq!(
1043+
replay.section_offsets.get(&ReplaySection::ShieldBattery),
1044+
None
1045+
);
1046+
}
9681047
}

0 commit comments

Comments
 (0)