From 2d13e95d7f1c6d85453b2f98543b054b6bc06cde Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sun, 4 Feb 2018 00:22:14 -0600 Subject: [PATCH] Add encode/decode tests, skip for save --- tests/apple2.dd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/apple2.dd.c b/tests/apple2.dd.c index 7af30df..f45ffa2 100644 --- a/tests/apple2.dd.c +++ b/tests/apple2.dd.c @@ -173,3 +173,29 @@ Test(apple2_dd, write_protect) apple2_dd_write_protect(drive, 2222); cr_assert(drive->write_protect); } + +Test(apple2_dd, encode) +{ + // Mostly we want to test if this handles the image types correct. + // The encode function won't actually try to encode anything if the + // image segment is NULL. + drive->image_type = DD_NIBBLE; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = DD_DOS33; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = DD_PRODOS; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = -1; cr_assert_neq(apple2_dd_encode(drive), OK); +} + +Test(apple2_dd, decode) +{ + // Same drill as for the encode test + drive->image_type = DD_NIBBLE; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = DD_DOS33; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = DD_PRODOS; cr_assert_eq(apple2_dd_encode(drive), OK); + drive->image_type = -1; cr_assert_neq(apple2_dd_encode(drive), OK); +} + +// Skipping this test because most everything it does is already tested +// in some other capacity +/* Test(apple2_dd, save) */ + +