Build out MATLAB test framework and core integration coverage

This commit is contained in:
Silas Oettinghaus
2026-03-24 17:23:02 +01:00
parent 9446dfb888
commit a592ebefda
154 changed files with 2281 additions and 1305 deletions

View File

@@ -1,11 +1,49 @@
classdef Scope_test < matlab.unittest.TestCase
% Test class for Scope
classdef Scope_test < IMDDTestCase
methods (Test, TestTags = {'unit', 'fast', 'receive', 'scope'})
function quantizeMapsRealSignalToExpectedGrid(testCase)
scope = makeScope(10, 10, 2, 0, true);
xin = (0:9).';
methods (Test)
function testExample(testCase)
% Example test case for Scope
% Add your test code here
testCase.verifyTrue(true);
quantized = scope.quantize(xin);
expected = [0; 0; 8/3; 8/3; 16/3; 16/3; 16/3; 8; 8; 8];
testCase.verifyEqual(quantized, expected, "AbsTol", 1e-12);
end
function process_ResamplesQuantizesAndSubtractsDc(testCase)
scope = makeScope(40, 20, 3, 0, true);
xin = (1:40).';
yout = scope.process_(xin);
expected = scope.quantize(resample(xin, scope.fadc, scope.fsimu));
expected = expected - mean(expected, 1);
testCase.verifyEqual(length(yout), 20);
testCase.verifyEqual(yout, expected, "AbsTol", 1e-12);
testCase.verifyEqual(mean(yout), 0, "AbsTol", 1e-12);
end
function processWithoutDcBlockingPreservesQuantizedMean(testCase)
scope = makeScope(40, 20, 3, 0, false);
xin = (1:40).';
yout = scope.process_(xin);
expected = scope.quantize(resample(xin, scope.fadc, scope.fsimu));
testCase.verifyEqual(yout, expected, "AbsTol", 1e-12);
testCase.verifyGreaterThan(abs(mean(yout)), 1e-12);
end
end
end
function scope = makeScope(fsimu, fadc, adcresolution, quantbuffer, block_dc)
scope = Scope( ...
"fsimu", fsimu, ...
"fadc", fadc, ...
"adcresolution", adcresolution, ...
"quantbuffer", quantbuffer, ...
"block_dc", block_dc, ...
"H_lpf", struct('fs', fadc));
end