Skip to content

Commit cc11780

Browse files
committed
writer: ignore NUL padding data when pushing data for writing
1 parent 41bb3d8 commit cc11780

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ pub struct Cea608Writer {
377377
impl Cea608Writer {
378378
/// Push a [`Code`] into this writer
379379
pub fn push(&mut self, code: Code) {
380+
if code == Code::NUL {
381+
return;
382+
}
380383
self.pending.push_front(code)
381384
}
382385

@@ -758,6 +761,16 @@ mod test {
758761
assert_eq!(cea608.into_code(Field::ONE)[0], code);
759762
}
760763
}
764+
765+
#[test]
766+
fn writer_ignore_padding() {
767+
test_init_log();
768+
769+
let mut writer = Cea608Writer::default();
770+
writer.push(Code::NUL);
771+
writer.push(Code::LatinLowerA);
772+
assert_eq!(writer.pop(), [0x61, 0x80]);
773+
}
761774
}
762775

763776
#[cfg(test)]

0 commit comments

Comments
 (0)