Files
Aaru/Aaru.Tests/Images/CDRWin.cs

1029 lines
28 KiB
C#
Raw Normal View History

2020-07-23 14:28:34 +01:00
// /***************************************************************************
2020-07-25 02:01:36 +01:00
// Aaru Data Preservation Suite
2020-07-23 14:28:34 +01:00
// ----------------------------------------------------------------------------
//
// Filename : CDRWin.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
2020-07-25 02:01:36 +01:00
// Component : Aaru unit testing.
2020-07-23 14:28:34 +01:00
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2020-12-31 23:08:23 +00:00
// Copyright © 2011-2021 Natalia Portillo
2020-07-23 14:28:34 +01:00
// ****************************************************************************/
using System;
using System.IO;
using System.Linq;
2020-07-23 14:28:34 +01:00
using Aaru.Checksums;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Structs;
using Aaru.DiscImages;
using Aaru.Filters;
using FluentAssertions;
using FluentAssertions.Execution;
2020-07-23 14:28:34 +01:00
using NUnit.Framework;
namespace Aaru.Tests.Images
{
[TestFixture]
public class CDRWin
{
readonly string[] _testFiles =
{
2021-01-09 17:32:02 +00:00
"pcengine.cue", "pcfx.cue", "report_audiocd.cue", "report_cdr.cue", "report_cdrw.cue",
"test_audiocd_cdtext.cue", "test_incd_udf200_finalized.cue", "test_multi_karaoke_sampler.cue",
"test_multiple_indexes.cue", "test_videocd.cue", "cdg/report_audiocd.cue",
"cdg/test_multi_karaoke_sampler.cue", "cooked_cdg/test_multi_karaoke_sampler.cue",
"cooked/report_cdrom.cue", "cooked/report_cdrw.cue", "cooked/test_multi_karaoke_sampler.cue"
2020-07-23 14:28:34 +01:00
};
readonly ulong[] _sectors =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
160356,
// pcfx.cue
246305,
// report_audiocd.cue
247073,
// report_cdr.cue
254265,
// report_cdrw.cue
308224,
// test_audiocd_cdtext.cue
277696,
// test_incd_udf200_finalized.cue
350134,
// test_multi_karaoke_sampler.cue
329008,
// test_multiple_indexes.cue
65536,
// test_videocd.cue
48794,
// cdg/report_audiocd.cue
247073,
// cdg/test_multi_karaoke_sampler.cue
329008,
// cooked_cdg/test_multi_karaoke_sampler.cue
329008,
// cooked/report_cdrom.cue
254265,
// cooked/report_cdrw.cue
308224,
// cooked/test_multi_karaoke_sampler.cue
329008
2020-07-23 14:28:34 +01:00
};
readonly MediaType[] _mediaTypes =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
MediaType.CD,
// pcfx.cue
MediaType.CD,
// report_audiocd.cue
MediaType.CDDA,
// report_cdr.cue
MediaType.CDROM,
// report_cdrw.cue
MediaType.CDROM,
// test_audiocd_cdtext.cue
MediaType.CDDA,
// test_incd_udf200_finalized.cue
MediaType.CDROMXA,
// test_multi_karaoke_sampler.cue
MediaType.CDROMXA,
// test_multiple_indexes.cue
MediaType.CDDA,
// test_videocd.cue
MediaType.CDROMXA,
// cdg/report_audiocd.cue
MediaType.CDDA,
// cdg/test_multi_karaoke_sampler.cue
MediaType.CDROMXA,
// cooked_cdg/test_multi_karaoke_sampler.cue
MediaType.CDROMXA,
// cooked/report_cdrom.cue
MediaType.CDROM,
// cooked/report_cdrw.cue
MediaType.CDROM,
// cooked/test_multi_karaoke_sampler.cue
MediaType.CDROMXA
2020-07-23 14:28:34 +01:00
};
readonly string[] _md5S =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
"8eb436b476c9df343acb89ac1ba7e1b4",
// pcfx.cue
"73e2855fff156f95fb8f0ae7c58d1b9d",
// report_audiocd.cue
"c09f408a4416634d8ac1c1ffd0ed75a5",
// report_cdr.cue
"bf4bbec517101d0d6f45d2e4d50cb875",
// report_cdrw.cue
"1e55aa420ca8f8ea77d5b597c9cfc19b",
// test_audiocd_cdtext.cue
"7c8fc7bb768cff15d702ac8cd10108d7",
// test_incd_udf200_finalized.cue
"13d4c3def37e968b2ddc5cf5a9f18fdc",
// test_multi_karaoke_sampler.cue
"f09312ba25a479fb81912a2965babd22",
// test_multiple_indexes.cue
"1b13a8f8aeb23f0b8bbc68518217e771",
// test_videocd.cue
"0d80890beeadf3f6e2cf2f88d0067afe",
// cdg/report_audiocd.cue
"c09f408a4416634d8ac1c1ffd0ed75a5",
// cdg/test_multi_karaoke_sampler.cue
"f09312ba25a479fb81912a2965babd22",
// cooked_cdg/test_multi_karaoke_sampler.cue
"f09312ba25a479fb81912a2965babd22",
// cooked/report_cdrom.cue
"bf4bbec517101d0d6f45d2e4d50cb875",
// cooked/report_cdrw.cue
"1e55aa420ca8f8ea77d5b597c9cfc19b",
// cooked/test_multi_karaoke_sampler.cue
"f09312ba25a479fb81912a2965babd22"
2020-07-23 14:28:34 +01:00
};
readonly string[] _longMd5S =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
"bdcd5cabf4f48333f9dbb08967dce7a8",
// pcfx.cue
"f421fc4af3ac528911b6d824825ff9b5",
// report_audiocd.cue
"c09f408a4416634d8ac1c1ffd0ed75a5",
// report_cdr.cue
"3d3f9cf7d1ba2249b1e7960071e5af46",
// report_cdrw.cue
"3af5f943ddb9427d9c63a4ce3b704db9",
// test_audiocd_cdtext.cue
"7c8fc7bb768cff15d702ac8cd10108d7",
// test_incd_udf200_finalized.cue
"31e772f6997eb8dbf3ecf9aca9ea6bc6",
// test_multi_karaoke_sampler.cue
"f48603d11883593f45ec4a3824681e4e",
// test_multiple_indexes.cue
"1b13a8f8aeb23f0b8bbc68518217e771",
// test_videocd.cue
"96ac6c364e4c3cb2f043197a45a97183",
// cdg/report_audiocd.cue
"c09f408a4416634d8ac1c1ffd0ed75a5",
// cdg/test_multi_karaoke_sampler.cue
"f48603d11883593f45ec4a3824681e4e",
// cooked_cdg/test_multi_karaoke_sampler.cue
"UNKNOWN",
// cooked/report_cdrom.cue
"3d3f9cf7d1ba2249b1e7960071e5af46",
// cooked/report_cdrw.cue
"3af5f943ddb9427d9c63a4ce3b704db9",
// cooked/test_multi_karaoke_sampler.cue
"f48603d11883593f45ec4a3824681e4e"
2020-07-23 14:28:34 +01:00
};
readonly string[] _subchannelMd5S =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
null,
// pcfx.cue
null,
// report_audiocd.cue
null,
// report_cdr.cue
null,
// report_cdrw.cue
null,
// test_audiocd_cdtext.cue
null,
// test_incd_udf200_finalized.cue
null,
// test_multi_karaoke_sampler.cue
null,
// test_multiple_indexes.cue
null,
// test_videocd.cue
null,
// cdg/report_audiocd.cue
"UNKNOWN",
// cdg/test_multi_karaoke_sampler.cue
"UNKNOWN",
// cooked_cdg/test_multi_karaoke_sampler.cue
"UNKNOWN",
// cooked/report_cdrom.cue
null,
// cooked/report_cdrw.cue
null,
// cooked/test_multi_karaoke_sampler.cue
null
2020-07-23 14:28:34 +01:00
};
readonly int[] _tracks =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
16,
// pcfx.cue
8,
// report_audiocd.cue
14,
// report_cdr.cue
1,
// report_cdrw.cue
1,
// test_audiocd_cdtext.cue
11,
// test_incd_udf200_finalized.cue
1,
// test_multi_karaoke_sampler.cue
16,
// test_multiple_indexes.cue
5,
// test_videocd.cue
2,
// cdg/report_audiocd.cue
14,
// cdg/test_multi_karaoke_sampler.cue
16,
// cooked_cdg/test_multi_karaoke_sampler.cue
16,
// cooked/report_cdrom.cue
1,
// cooked/report_cdrw.cue
1,
// cooked/test_multi_karaoke_sampler.cue
16
2020-07-23 14:28:34 +01:00
};
readonly int[][] _trackSessions =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// pcfx.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1
},
// report_audiocd.cue
new[]
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_cdr.cue
2020-07-23 14:28:34 +01:00
new[]
{
1
},
2021-01-09 17:32:02 +00:00
// report_cdrw.cue
2020-07-23 14:28:34 +01:00
new[]
{
1
},
2021-01-09 17:32:02 +00:00
// test_audiocd_cdtext.cue
new[]
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
},
// test_incd_udf200_finalized.cue
2020-07-23 14:28:34 +01:00
new[]
{
1
},
2021-01-09 17:32:02 +00:00
// test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multiple_indexes.cue
new[]
{
1, 1, 1, 1, 1
},
// test_videocd.cue
2020-07-23 14:28:34 +01:00
new[]
{
1, 1
},
2021-01-09 17:32:02 +00:00
// cdg/report_audiocd.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked_cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new[]
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
},
2021-01-09 17:32:02 +00:00
// cooked/report_cdrom.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1
},
// cooked/report_cdrw.cue
new[]
{
1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new[]
{
2021-01-09 17:32:02 +00:00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2020-07-23 14:28:34 +01:00
}
};
readonly ulong[][] _trackStarts =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 3365, 38239, 46692, 52976, 61294, 68038, 74872, 82605, 85956, 90742, 98749, 106168, 111713, 119745,
125629
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// pcfx.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 4170, 4684, 5716, 41834, 220420, 225121, 234973
},
// report_audiocd.cue
new ulong[]
{
0, 16399, 29901, 47800, 63164, 78775, 94582, 116975, 136016, 153922, 170601, 186389, 201649, 224299
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_cdr.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
0
},
2021-01-09 17:32:02 +00:00
// report_cdrw.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
0
},
2021-01-09 17:32:02 +00:00
// test_audiocd_cdtext.cue
new ulong[]
{
0, 29752, 65034, 78426, 95080, 126147, 154959, 191685, 222776, 243438, 269600
},
// test_incd_udf200_finalized.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
0
},
2021-01-09 17:32:02 +00:00
// test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 1737, 32449, 52372, 70004, 99798, 119461, 136699, 155490, 175526, 206161, 226150, 244055, 273665,
293452, 310411
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multiple_indexes.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 4654, 13725, 41035, 54839
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_videocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 1252
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/report_audiocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 16399, 29901, 47800, 63164, 78775, 94582, 116975, 136016, 153922, 170601, 186389, 201649, 224299
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 1737, 32449, 52372, 70004, 99798, 119461, 136699, 155490, 175526, 206161, 226150, 244055, 273665,
293452, 310411
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked_cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0, 1737, 32449, 52372, 70004, 99798, 119461, 136699, 155490, 175526, 206161, 226150, 244055, 273665,
293452, 310411
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked/report_cdrom.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
0
},
// cooked/report_cdrw.cue
new ulong[]
{
0
},
// cooked/test_multi_karaoke_sampler.cue
new ulong[]
{
0, 1737, 32449, 52372, 70004, 99798, 119461, 136699, 155490, 175526, 206161, 226150, 244055, 273665,
293452, 310411
2020-07-23 14:28:34 +01:00
}
};
readonly ulong[][] _trackEnds =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
3364, 38238, 46691, 52975, 61293, 68037, 74871, 82604, 85955, 90741, 98748, 106167, 111712, 119744,
125628, 160355
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// pcfx.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
4169, 4683, 5715, 41833, 220419, 225120, 234972, 246304
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_audiocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
16398, 29900, 47799, 63163, 78774, 94581, 116974, 136015, 153921, 170600, 186388, 201648, 224298, 247072
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_cdr.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
254264
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_cdrw.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
308223
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_audiocd_cdtext.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
29751, 65033, 78425, 95079, 126146, 154958, 191684, 222775, 243437, 269599, 277695
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_incd_udf200_finalized.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
350133
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
1736, 32448, 52371, 70003, 99797, 119460, 136698, 155489, 175525, 206160, 226149, 244054, 273664,
293451, 310410, 329007
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multiple_indexes.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
4653, 13724, 41034, 54838, 65535
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_videocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
1251, 48793
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/report_audiocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
16398, 29900, 47799, 63163, 78774, 94581, 116974, 136015, 153921, 170600, 186388, 201648, 224298, 247072
},
// cdg/test_multi_karaoke_sampler.cue
new ulong[]
{
1736, 32448, 52371, 70003, 99797, 119460, 136698, 155489, 175525, 206160, 226149, 244054, 273664,
293451, 310410, 329007
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked_cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
1736, 32448, 52371, 70003, 99797, 119460, 136698, 155489, 175525, 206160, 226149, 244054, 273664,
293451, 310410, 329007
},
// cooked/report_cdrom.cue
new ulong[]
{
254264
},
// cooked/report_cdrw.cue
new ulong[]
{
308223
},
// cooked/test_multi_karaoke_sampler.cue
new ulong[]
{
1736, 32448, 52371, 70003, 99797, 119460, 136698, 155489, 175525, 206160, 226149, 244054, 273664,
293451, 310410, 329007
2020-07-23 14:28:34 +01:00
}
};
readonly ulong[][] _trackPregaps =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 225, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 225
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// pcfx.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 225, 0, 0, 0, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_audiocd.cue
new ulong[]
{
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
},
// report_cdr.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
150
},
2021-01-09 17:32:02 +00:00
// report_cdrw.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
150
},
2021-01-09 17:32:02 +00:00
// test_audiocd_cdtext.cue
new ulong[]
{
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
},
// test_incd_udf200_finalized.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
150
},
2021-01-09 17:32:02 +00:00
// test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multiple_indexes.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_videocd.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 0
},
// cdg/report_audiocd.cue
new ulong[]
{
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked_cdg/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked/report_cdrom.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cooked/report_cdrw.cue
new ulong[]
{
150
},
// cooked/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new ulong[]
{
2021-01-09 17:32:02 +00:00
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150
2020-07-23 14:28:34 +01:00
}
};
readonly byte[][] _trackFlags =
{
2021-01-09 17:32:02 +00:00
// pcengine.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// pcfx.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
0, 4, 4, 4, 4, 0, 0, 0
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_audiocd.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// report_cdr.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
4
},
2021-01-09 17:32:02 +00:00
// report_cdrw.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
4
},
2021-01-09 17:32:02 +00:00
// test_audiocd_cdtext.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_incd_udf200_finalized.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
7
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_multiple_indexes.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
2, 0, 0, 8, 1
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// test_videocd.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
4, 4
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/report_audiocd.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2020-07-23 14:28:34 +01:00
},
2021-01-09 17:32:02 +00:00
// cdg/test_multi_karaoke_sampler.cue
new byte[]
{
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
// cooked_cdg/test_multi_karaoke_sampler.cue
new byte[]
{
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
// cooked/report_cdrom.cue
new byte[]
{
4
},
// cooked/report_cdrw.cue
new byte[]
{
4
},
// cooked/test_multi_karaoke_sampler.cue
2020-07-23 14:28:34 +01:00
new byte[]
{
2021-01-09 17:32:02 +00:00
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2020-07-23 14:28:34 +01:00
}
};
readonly string _dataFolder = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "CDRWin");
2020-07-23 14:28:34 +01:00
[Test]
public void Info()
2020-07-23 14:28:34 +01:00
{
Environment.CurrentDirectory = _dataFolder;
for(int i = 0; i < _testFiles.Length; i++)
{
var filter = new ZZZNoFilter();
filter.Open(_testFiles[i]);
var image = new CdrWin();
bool opened = image.Open(filter);
Assert.AreEqual(true, opened, $"Open: {_testFiles[i]}");
2020-07-23 14:28:34 +01:00
using(new AssertionScope())
{
Assert.Multiple(() =>
{
Assert.AreEqual(_sectors[i], image.Info.Sectors, $"Sectors: {_testFiles[i]}");
Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, $"Media type: {_testFiles[i]}");
Assert.AreEqual(_tracks[i], image.Tracks.Count, $"Tracks: {_testFiles[i]}");
image.Tracks.Select(t => t.TrackSession).Should().
BeEquivalentTo(_trackSessions[i], $"Track session: {_testFiles[i]}");
image.Tracks.Select(t => t.TrackStartSector).Should().
BeEquivalentTo(_trackStarts[i], $"Track start: {_testFiles[i]}");
2020-07-23 14:28:34 +01:00
image.Tracks.Select(t => t.TrackEndSector).Should().
BeEquivalentTo(_trackEnds[i], $"Track end: {_testFiles[i]}");
image.Tracks.Select(t => t.TrackPregap).Should().
BeEquivalentTo(_trackPregaps[i], $"Track pregap: {_testFiles[i]}");
int trackNo = 0;
byte[] flags = new byte[image.Tracks.Count];
2020-07-23 14:28:34 +01:00
foreach(Track currentTrack in image.Tracks)
{
if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags))
flags[trackNo] = image.ReadSectorTag(currentTrack.TrackSequence,
SectorTagType.CdTrackFlags)[0];
2020-07-23 14:28:34 +01:00
trackNo++;
}
flags.Should().BeEquivalentTo(_trackFlags[i], $"Track flags: {_testFiles[i]}");
});
2020-07-23 14:28:34 +01:00
}
}
}
2020-07-23 14:28:34 +01:00
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
[Test]
public void Hashes()
{
Environment.CurrentDirectory = _dataFolder;
Assert.Multiple(() =>
{
for(int i = 0; i < _testFiles.Length; i++)
2020-07-23 14:28:34 +01:00
{
var filter = new ZZZNoFilter();
filter.Open(_testFiles[i]);
var image = new CdrWin();
bool opened = image.Open(filter);
Assert.AreEqual(true, opened, $"Open: {_testFiles[i]}");
Md5Context ctx;
2020-07-23 14:28:34 +01:00
foreach(bool @long in new[]
2020-07-23 14:28:34 +01:00
{
false, true
})
{
ctx = new Md5Context();
2020-07-23 14:28:34 +01:00
foreach(Track currentTrack in image.Tracks)
2020-07-23 14:28:34 +01:00
{
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
ulong doneSectors = 0;
2020-07-23 14:28:34 +01:00
while(doneSectors < sectors)
2020-07-23 14:28:34 +01:00
{
byte[] sector;
if(sectors - doneSectors >= SECTORS_TO_READ)
{
sector =
@long ? image.ReadSectorsLong(doneSectors, SECTORS_TO_READ,
currentTrack.TrackSequence)
: image.ReadSectors(doneSectors, SECTORS_TO_READ,
currentTrack.TrackSequence);
doneSectors += SECTORS_TO_READ;
}
else
{
sector =
@long ? image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors),
currentTrack.TrackSequence)
: image.ReadSectors(doneSectors, (uint)(sectors - doneSectors),
currentTrack.TrackSequence);
doneSectors += sectors - doneSectors;
}
ctx.Update(sector);
2020-07-23 14:28:34 +01:00
}
}
Assert.AreEqual(@long ? _longMd5S[i] : _md5S[i], ctx.End(),
$"{(@long ? "Long hash" : "Hash")}: {_testFiles[i]}");
2020-07-23 14:28:34 +01:00
}
if(!image.Info.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
continue;
2020-07-23 14:28:34 +01:00
ctx = new Md5Context();
2020-07-23 14:28:34 +01:00
foreach(Track currentTrack in image.Tracks)
2020-07-23 14:28:34 +01:00
{
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
2020-07-23 14:28:34 +01:00
ulong doneSectors = 0;
while(doneSectors < sectors)
{
byte[] sector;
if(sectors - doneSectors >= SECTORS_TO_READ)
2020-07-23 14:28:34 +01:00
{
sector = image.ReadSectorsTag(doneSectors, SECTORS_TO_READ, currentTrack.TrackSequence,
SectorTagType.CdSectorSubchannel);
2020-07-23 14:28:34 +01:00
doneSectors += SECTORS_TO_READ;
2020-07-23 14:28:34 +01:00
}
else
{
sector = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors),
currentTrack.TrackSequence,
SectorTagType.CdSectorSubchannel);
2020-07-23 14:28:34 +01:00
doneSectors += sectors - doneSectors;
}
ctx.Update(sector);
}
}
Assert.AreEqual(_subchannelMd5S[i], ctx.End(), $"Subchannel hash: {_testFiles[i]}");
2020-07-23 14:28:34 +01:00
}
});
2020-07-23 14:28:34 +01:00
}
}
}