50 lines
1.7 KiB
Matlab
50 lines
1.7 KiB
Matlab
classdef Scope_test < IMDDTestCase
|
|
methods (Test, TestTags = {'unit', 'fast', 'receive', 'scope'})
|
|
function quantizeMapsRealSignalToExpectedGrid(testCase)
|
|
scope = makeScope(10, 10, 2, 0, true);
|
|
xin = (0:9).';
|
|
|
|
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
|