Skip to content

Commit 1102c04

Browse files
HanSur94claude
andcommitted
fix: Octave test compatibility — replace contains(), fix Abstract classdef
- Replace contains() with strfind() in 6 Octave test files - Remove (Abstract) attribute from DataSource.m (unsupported in Octave) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a0c3705 commit 1102c04

7 files changed

Lines changed: 17 additions & 17 deletions

File tree

libs/EventDetection/DataSource.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef (Abstract) DataSource < handle
1+
classdef DataSource < handle
22
% DataSource Abstract interface for fetching new sensor data.
33
%
44
% Subclasses must implement fetchNew() which returns a struct:

tests/test_data_source.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function test_cannot_instantiate()
1818
ds = DataSource();
1919
error('Should not reach here');
2020
catch ex
21-
assert(contains(ex.message, 'Abstract'), 'cannot_instantiate');
21+
assert(~isempty(strfind(ex.message, 'Abstract')), 'cannot_instantiate');
2222
end
2323
fprintf(' PASS: test_cannot_instantiate\n');
2424
end

tests/test_data_source_map.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function test_unknown_key_errors()
4949
m.get('nope');
5050
error('Should not reach here');
5151
catch ex
52-
assert(contains(ex.identifier, 'unknownKey'), 'error_id');
52+
assert(~isempty(strfind(ex.identifier, 'unknownKey')), 'error_id');
5353
end
5454
fprintf(' PASS: test_unknown_key_errors\n');
5555
end

tests/test_event_console.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ function test_event_console()
1313
% testPrintEventSummary — should not error, should produce output
1414
out = evalc('printEventSummary(events)');
1515
assert(~isempty(out), 'printSummary: produces output');
16-
assert(contains(out, 'Temperature'), 'printSummary: contains sensor name');
17-
assert(contains(out, 'warning high'), 'printSummary: contains threshold label');
18-
assert(contains(out, 'Pressure'), 'printSummary: contains second sensor');
16+
assert(~isempty(strfind(out, 'Temperature')), 'printSummary: contains sensor name');
17+
assert(~isempty(strfind(out, 'warning high')), 'printSummary: contains threshold label');
18+
assert(~isempty(strfind(out, 'Pressure')), 'printSummary: contains second sensor');
1919

2020
% testPrintEventSummaryEmpty — should not error
2121
out = evalc('printEventSummary([])');
22-
assert(contains(out, 'No events'), 'printSummaryEmpty: no events message');
22+
assert(~isempty(strfind(out, 'No events')), 'printSummaryEmpty: no events message');
2323

2424
% testEventLogger — returns function handle
2525
logger = eventLogger();
@@ -28,9 +28,9 @@ function test_event_console()
2828
% testEventLoggerOutput — prints one-line log
2929
out = evalc('logger(e1)');
3030
assert(~isempty(out), 'eventLoggerOutput: produces output');
31-
assert(contains(out, 'EVENT'), 'eventLoggerOutput: contains EVENT tag');
32-
assert(contains(out, 'Temperature'), 'eventLoggerOutput: contains sensor name');
33-
assert(contains(out, 'warning high'), 'eventLoggerOutput: contains label');
31+
assert(~isempty(strfind(out, 'EVENT')), 'eventLoggerOutput: contains EVENT tag');
32+
assert(~isempty(strfind(out, 'Temperature')), 'eventLoggerOutput: contains sensor name');
33+
assert(~isempty(strfind(out, 'warning high')), 'eventLoggerOutput: contains label');
3434

3535
fprintf(' All 4 event_console tests passed.\n');
3636
end

tests/test_event_snapshot.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function test_generates_two_pngs()
3838
assert(numel(files) == 2, 'two_files');
3939
assert(isfile(files{1}), 'detail_exists');
4040
assert(isfile(files{2}), 'context_exists');
41-
assert(contains(files{1}, 'detail'), 'detail_name');
42-
assert(contains(files{2}, 'context'), 'context_name');
41+
assert(~isempty(strfind(files{1}, 'detail')), 'detail_name');
42+
assert(~isempty(strfind(files{2}, 'context')), 'context_name');
4343
rmdir(outDir, 's');
4444
fprintf(' PASS: test_generates_two_pngs\n');
4545
end

tests/test_event_store.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function test_event_store()
5353
EventViewer.fromFile('/tmp/nonexistent_event_store.mat');
5454
catch e
5555
threw = true;
56-
assert(contains(e.identifier, 'fileNotFound'), 'fromFile: correct error id');
56+
assert(~isempty(strfind(e.identifier, 'fileNotFound')), 'fromFile: correct error id');
5757
end
5858
assert(threw, 'fromFile: throws on missing file');
5959

tests/test_notification_rule.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ function test_fill_template()
5656
ev = Event(now, now + 1/24, 'temp', 'HH', 100, 'upper');
5757
ev.setStats(105, 10, 90, 105, 98, 99, 3);
5858
subj = r.fillTemplate(r.Subject, ev);
59-
assert(contains(subj, 'temp'), 'subj_sensor');
60-
assert(contains(subj, 'HH'), 'subj_threshold');
61-
assert(contains(subj, 'upper'), 'subj_direction');
59+
assert(~isempty(strfind(subj, 'temp')), 'subj_sensor');
60+
assert(~isempty(strfind(subj, 'HH')), 'subj_threshold');
61+
assert(~isempty(strfind(subj, 'upper')), 'subj_direction');
6262
msg = r.fillTemplate(r.Message, ev);
63-
assert(contains(msg, '105'), 'msg_peak');
63+
assert(~isempty(strfind(msg, '105')), 'msg_peak');
6464
fprintf(' PASS: test_fill_template\n');
6565
end

0 commit comments

Comments
 (0)