Hoffice push

This commit is contained in:
Silas
2024-09-06 15:53:32 +02:00
parent 03bfd70470
commit 179a7f9682
50 changed files with 921 additions and 93 deletions

View File

@@ -0,0 +1,11 @@
classdef Electricalsignal_test < matlab.unittest.TestCase
% Test class for Electricalsignal
methods (Test)
function testExample(testCase)
% Example test case for Electricalsignal
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Informationsignal_test < matlab.unittest.TestCase
% Test class for Informationsignal
methods (Test)
function testExample(testCase)
% Example test case for Informationsignal
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Opticalsignal_test < matlab.unittest.TestCase
% Test class for Opticalsignal
methods (Test)
function testExample(testCase)
% Example test case for Opticalsignal
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Signal_test < matlab.unittest.TestCase
% Test class for Signal
methods (Test)
function testExample(testCase)
% Example test case for Signal
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef AWG_test < matlab.unittest.TestCase
% Test class for AWG
methods (Test)
function testExample(testCase)
% Example test case for AWG
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef ChannelFreqResp_test < matlab.unittest.TestCase
% Test class for ChannelFreqResp
methods (Test)
function testExample(testCase)
% Example test case for ChannelFreqResp
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef M8196A_test < matlab.unittest.TestCase
% Test class for M8196A
methods (Test)
function testExample(testCase)
% Example test case for M8196A
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef M8199A_test < matlab.unittest.TestCase
% Test class for M8199A
methods (Test)
function testExample(testCase)
% Example test case for M8199A
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef M8199B_test < matlab.unittest.TestCase
% Test class for M8199B
methods (Test)
function testExample(testCase)
% Example test case for M8199B
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,67 @@
classdef PAMmapper_test < matlab.unittest.TestCase
properties
Digi_Mod
Tx_bits
Rx_bits
% M = 8; % Modulation order
fsym = 112e9; % Symbol rate
end
properties (TestParameter)
M = {4,6,8};
end
methods (TestMethodSetup)
function setupModulation(testCase)
% Setup PRBS and bit pattern for the test case
O = 10; % Order of PRBS
N = 2^(O-1); % Length of PRBS
useprbs = 1; % Flag to use PRBS
randkey = 1; % Random key for random stream
[~, seed] = prbs(O, 1); % Initialize first seed of PRBS
bitpattern = [];
if useprbs
for i = 1:log2(testCase.M)
[bitpattern(:, i), seed] = prbs(O, N, seed);
end
else
s = RandStream('twister', 'Seed', randkey);
for i = 1:log2(testCase.M)
bitpattern(:, i) = randi(s, [0 1], N, 1);
end
end
if testCase.M == 6
bitpattern = reshape(bitpattern, [], 1);
bitpattern = bitpattern(1:end-mod(length(bitpattern), 5));
end
testCase.Tx_bits = Informationsignal(bitpattern);
testCase.Digi_Mod = PAMmapper(testCase.M, 0);
end
end
methods (Test)
function testBackToBackMapping(testCase)
% Test Bits -> Symbols -> Bits (Back-to-Back Mapping)
% Map bits to symbols
Symbols = testCase.Digi_Mod.map(testCase.Tx_bits);
% Demap symbols back to bits
testCase.Rx_bits = testCase.Digi_Mod.demap(Symbols);
% Validate BER is zero
[~, error_num, ber, ~] = calc_ber(testCase.Tx_bits.signal, testCase.Rx_bits.signal, ...
"skip_front", 0, "skip_end", 0, "returnErrorLocation", 1);
% Assert that BER is zero
testCase.verifyEqual(ber, 0, 'BER should be zero');
testCase.verifyEqual(error_num, 0, 'No errors should occur in the mapping process');
end
end
end

View File

@@ -0,0 +1,11 @@
classdef PAMsource_test < matlab.unittest.TestCase
% Test class for PAMsource
methods (Test)
function testExample(testCase)
% Example test case for PAMsource
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Pulseformer_test < matlab.unittest.TestCase
% Test class for Pulseformer
methods (Test)
function testExample(testCase)
% Example test case for Pulseformer
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Signalgenerator_test < matlab.unittest.TestCase
% Test class for Signalgenerator
methods (Test)
function testExample(testCase)
% Example test case for Signalgenerator
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Amplifier_test < matlab.unittest.TestCase
% Test class for Amplifier
methods (Test)
function testExample(testCase)
% Example test case for Amplifier
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Filter_test < matlab.unittest.TestCase
% Test class for Filter
methods (Test)
function testExample(testCase)
% Example test case for Filter
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EML_test < matlab.unittest.TestCase
% Test class for EML
methods (Test)
function testExample(testCase)
% Example test case for EML
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Fiber_test < matlab.unittest.TestCase
% Test class for Fiber
methods (Test)
function testExample(testCase)
% Example test case for Fiber
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Photodiode_test < matlab.unittest.TestCase
% Test class for Photodiode
methods (Test)
function testExample(testCase)
% Example test case for Photodiode
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Scope_test < matlab.unittest.TestCase
% Test class for Scope
methods (Test)
function testExample(testCase)
% Example test case for Scope
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef Duobinary_test < matlab.unittest.TestCase
% Test class for Duobinary
methods (Test)
function testExample(testCase)
% Example test case for Duobinary
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef MRDS_coding_test < matlab.unittest.TestCase
% Test class for MRDS_coding
methods (Test)
function testExample(testCase)
% Example test case for MRDS_coding
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_copy_test < matlab.unittest.TestCase
% Test class for EQ_copy
methods (Test)
function testExample(testCase)
% Example test case for EQ_copy
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_silas_ofc_test < matlab.unittest.TestCase
% Test class for EQ_silas_ofc
methods (Test)
function testExample(testCase)
% Example test case for EQ_silas_ofc
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_silas_plain_test < matlab.unittest.TestCase
% Test class for EQ_silas_plain
methods (Test)
function testExample(testCase)
% Example test case for EQ_silas_plain
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_silas_sliding_window_dc_removal_test < matlab.unittest.TestCase
% Test class for EQ_silas_sliding_window_dc_removal
methods (Test)
function testExample(testCase)
% Example test case for EQ_silas_sliding_window_dc_removal
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_silas_test < matlab.unittest.TestCase
% Test class for EQ_silas
methods (Test)
function testExample(testCase)
% Example test case for EQ_silas
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef EQ_test < matlab.unittest.TestCase
% Test class for EQ
methods (Test)
function testExample(testCase)
% Example test case for EQ
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef FFE_DCremoval_test < matlab.unittest.TestCase
% Test class for FFE_DCremoval
methods (Test)
function testExample(testCase)
% Example test case for FFE_DCremoval
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef FFE_DFE_test < matlab.unittest.TestCase
% Test class for FFE_DFE
methods (Test)
function testExample(testCase)
% Example test case for FFE_DFE
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef FFE_FFDCAVG_test < matlab.unittest.TestCase
% Test class for FFE_FFDCAVG
methods (Test)
function testExample(testCase)
% Example test case for FFE_FFDCAVG
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef FFE_adaptive_decision_test < matlab.unittest.TestCase
% Test class for FFE_adaptive_decision
methods (Test)
function testExample(testCase)
% Example test case for FFE_adaptive_decision
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef FFE_test < matlab.unittest.TestCase
% Test class for FFE
methods (Test)
function testExample(testCase)
% Example test case for FFE
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef VNLE_test < matlab.unittest.TestCase
% Test class for VNLE
methods (Test)
function testExample(testCase)
% Example test case for VNLE
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef MLSE_test < matlab.unittest.TestCase
% Test class for MLSE
methods (Test)
function testExample(testCase)
% Example test case for MLSE
% Add your test code here
testCase.verifyTrue(true);
end
end
end

View File

@@ -0,0 +1,11 @@
classdef class_template_test < matlab.unittest.TestCase
% Test class for class_template
methods (Test)
function testExample(testCase)
% Example test case for class_template
% Add your test code here
testCase.verifyTrue(true);
end
end
end

23
Tests/createTestFile.m Normal file
View File

@@ -0,0 +1,23 @@
function createTestFile(className, testFilePath)
% Open the file for writing
fid = fopen(testFilePath, 'w');
% Write the basic structure for the test class
fprintf(fid, 'classdef %s_test < matlab.unittest.TestCase\n', className);
fprintf(fid, ' %% Test class for %s\n\n', className);
fprintf(fid, ' methods (Test)\n');
fprintf(fid, ' function testExample(testCase)\n');
fprintf(fid, ' %% Example test case for %s\n', className);
fprintf(fid, ' %% Add your test code here\n');
fprintf(fid, ' testCase.verifyTrue(true);\n');
fprintf(fid, ' end\n');
fprintf(fid, ' end\n');
fprintf(fid, 'end\n');
% Close the file
fclose(fid);
fprintf('Created test file: %s\n', testFilePath);
end

46
Tests/generateTests.m Normal file
View File

@@ -0,0 +1,46 @@
function generateTests()
if ismac
cd('/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation');
else
end
% Define the root folders for classes and tests
classesFolder = 'Classes'; % Folder containing the class files
testsFolder = 'Tests'; % Folder where test files should be created
% Create the Test folder if it doesn't exist
if ~exist(testsFolder, 'dir')
mkdir(testsFolder);
end
% Get all .m files in the Classes folder and its subfolders
classFiles = dir(fullfile(classesFolder, '**', '*.m'));
% Iterate over all class files
for i = 1:length(classFiles)
classFilePath = fullfile(classFiles(i).folder, classFiles(i).name);
[~, className, ~] = fileparts(classFilePath);
% Create corresponding test file name
testFileName = [className, '_test.m'];
testFilePath = strrep(classFilePath, classesFolder, testsFolder); % Replace folder
testFilePath = fullfile(fileparts(testFilePath), testFileName); % Append test filename
% Check if the test file already exists
if ~exist(testFilePath, 'file')
% Create the test subfolder if it doesn't exist
testSubFolder = fileparts(testFilePath);
if ~exist(testSubFolder, 'dir')
mkdir(testSubFolder);
end
% Write the skeleton test file
createTestFile(className, testFilePath);
end
end
addpath(genpath(testsFolder))
end