Skip to content

Add comprehensive tests for Speaker and DistanceSensor classes#140

Merged
pjbRPF merged 4 commits into
devfrom
patch/add_speaker_and_distance_sensor_tests
Nov 28, 2025
Merged

Add comprehensive tests for Speaker and DistanceSensor classes#140
pjbRPF merged 4 commits into
devfrom
patch/add_speaker_and_distance_sensor_tests

Conversation

@pjbRPF

@pjbRPF pjbRPF commented Nov 26, 2025

Copy link
Copy Markdown
Contributor
  • test_speaker_default_values: Tests basic Speaker initialization with default freq (440Hz) and volume (0)
  • test_speaker_alt_values: Tests custom initial_freq and initial_volume parameters with delta tolerance for PWM frequency variations
  • test_speaker_note_conversion: Tests _to_freq() method for string notes, MIDI notes, and direct frequency values
  • test_speaker_play_single_note: Tests playing a single note and verifies volume is 0 after playback
  • test_speaker_play_note_list: Tests playing a sequence of notes with durations
  • test_distance_sensor_basic: Tests DistanceSensor initialization with default max_distance (1.0m)
  • test_distance_sensor_custom_max_distance: Tests custom max_distance parameter

Speaker tests use pins 15-19, DistanceSensor tests use pins 22-25 to avoid conflicts.
Uses assertAlmostEqual with delta=10 for PWM frequency assertions to account for hardware limitations.

- test_speaker_default_values: Tests basic Speaker initialization with default freq (440Hz) and volume (0)
- test_speaker_alt_values: Tests custom initial_freq and initial_volume parameters with delta tolerance for PWM frequency variations
- test_speaker_note_conversion: Tests _to_freq() method for string notes, MIDI notes, and direct frequency values
- test_speaker_play_single_note: Tests playing a single note and verifies volume is 0 after playback
- test_speaker_play_note_list: Tests playing a sequence of notes with durations
- test_distance_sensor_basic: Tests DistanceSensor initialization with default max_distance (1.0m)
- test_distance_sensor_custom_max_distance: Tests custom max_distance parameter

Speaker tests use pins 15-19, DistanceSensor tests use pins 22-25 to avoid conflicts.
Uses assertAlmostEqual with delta=10 for PWM frequency assertions to account for hardware limitations.
@pjbRPF pjbRPF requested a review from MarcScott as a code owner November 26, 2025 12:25
@pjbRPF pjbRPF self-assigned this Nov 26, 2025
@pjbRPF

pjbRPF commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

Fixes #10

@pjbRPF pjbRPF linked an issue Nov 26, 2025 that may be closed by this pull request
@pjbRPF pjbRPF changed the base branch from main to dev November 28, 2025 11:24
@pjbRPF pjbRPF merged commit 96610c9 into dev Nov 28, 2025
@pjbRPF pjbRPF deleted the patch/add_speaker_and_distance_sensor_tests branch November 28, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create automated test process

2 participants