Build out MATLAB test framework and core integration coverage
This commit is contained in:
@@ -1,11 +1,81 @@
|
||||
classdef TransmissionPerformance_test < matlab.unittest.TestCase
|
||||
% Test class for TransmissionPerformance
|
||||
classdef TransmissionPerformance_test < IMDDTestCase
|
||||
methods (Test, TestTags = {'unit', 'fast', 'dsp', 'transmissionperformance'})
|
||||
function ngmiLookupSelectsExpectedSDHDRows(testCase)
|
||||
tp = TransmissionPerformance();
|
||||
grossRate = 10e9;
|
||||
ngmi = [0.8120, 0.8746, 1.0000];
|
||||
|
||||
methods (Test)
|
||||
function testExample(testCase)
|
||||
% Example test case for TransmissionPerformance
|
||||
% Add your test code here
|
||||
testCase.verifyTrue(true);
|
||||
out = tp.calculateNetRate(grossRate, 'NGMI', ngmi);
|
||||
|
||||
expectedIdx = [1, 10, 30];
|
||||
expectedCodeRate = tp.OVERALLCODERATES_SDHD(expectedIdx);
|
||||
expectedThreshold = tp.NGMITHRESHOLDS_SDHD(expectedIdx);
|
||||
expectedNetRate = grossRate .* expectedCodeRate;
|
||||
expectedPunct = tp.ISPUNCT_LDPI(expectedIdx);
|
||||
|
||||
testCase.verifyEqual(out.SDHD.GrossRate, repmat(grossRate, 1, numel(ngmi)));
|
||||
testCase.verifyEqual(out.SDHD.CodeRate, expectedCodeRate, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.SDHD.Threshold, expectedThreshold, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.SDHD.NetRate, expectedNetRate, 'AbsTol', 1e-6);
|
||||
testCase.verifyEqual(out.SDHD.punctLDPI, expectedPunct);
|
||||
end
|
||||
|
||||
function berLookupSelectsExpectedSTAIRRowsForVectorInput(testCase)
|
||||
tp = TransmissionPerformance();
|
||||
grossRate = [100e9, 200e9, 300e9];
|
||||
ber = [1e-4, 1e-2, 2e-2];
|
||||
|
||||
out = tp.calculateNetRate(grossRate, 'BER', ber);
|
||||
|
||||
expectedIdx = [11, 6, 1];
|
||||
expectedCodeRate = tp.CODE_RATES_HD(expectedIdx);
|
||||
expectedThreshold = tp.BERTHRESHOLDS_HD(expectedIdx);
|
||||
expectedNetRate = grossRate .* expectedCodeRate;
|
||||
|
||||
testCase.verifyEqual(out.STAIR.GrossRate, grossRate);
|
||||
testCase.verifyEqual(out.STAIR.CodeRate, expectedCodeRate, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.STAIR.Threshold, expectedThreshold, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.STAIR.NetRate, expectedNetRate, 'AbsTol', 1e-6);
|
||||
end
|
||||
|
||||
function berLookupPopulatesSpecialFecModesForLowBer(testCase)
|
||||
tp = TransmissionPerformance();
|
||||
grossRate = 100e9;
|
||||
ber = 1e-4;
|
||||
|
||||
out = tp.calculateNetRate(grossRate, 'BER', ber);
|
||||
|
||||
testCase.verifyEqual(out.KP4.CodeRate, tp.CODE_RATE_KP4, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.KP4.NetRate, grossRate * tp.CODE_RATE_KP4, 'AbsTol', 1e-6);
|
||||
testCase.verifyEqual(out.KP4_hamming.CodeRate, tp.CODE_RATE_KP4_AND_INNER, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.KP4_hamming.NetRate, grossRate * tp.CODE_RATE_KP4_AND_INNER, 'AbsTol', 1e-6);
|
||||
testCase.verifyEqual(out.O_FEC.CodeRate, tp.CODE_RATE_O_FEC, 'AbsTol', 1e-12);
|
||||
testCase.verifyEqual(out.O_FEC.NetRate, grossRate * tp.CODE_RATE_O_FEC, 'AbsTol', 1e-6);
|
||||
end
|
||||
|
||||
function outOfRangeBerLeavesAllRatesUndefined(testCase)
|
||||
tp = TransmissionPerformance();
|
||||
grossRate = [50e9, 60e9];
|
||||
ber = [0.1, 0.05];
|
||||
|
||||
out = tp.calculateNetRate(grossRate, 'BER', ber);
|
||||
|
||||
testCase.verifyTrue(all(isnan(out.STAIR.CodeRate)));
|
||||
testCase.verifyTrue(all(isnan(out.KP4.CodeRate)));
|
||||
testCase.verifyTrue(all(isnan(out.KP4_hamming.CodeRate)));
|
||||
testCase.verifyTrue(all(isnan(out.O_FEC.CodeRate)));
|
||||
end
|
||||
|
||||
function missingQualityInputRaisesTheDocumentedError(testCase)
|
||||
tp = TransmissionPerformance();
|
||||
|
||||
try
|
||||
tp.calculateNetRate(10e9);
|
||||
testCase.assertFail('Expected calculateNetRate to error when BER and NGMI are both omitted.');
|
||||
catch ME
|
||||
testCase.verifyThat(ME.message, matlab.unittest.constraints.ContainsSubstring( ...
|
||||
'At least one of ''BER'' or ''NGMI'' must be provided.'));
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user