-
-
Notifications
You must be signed in to change notification settings - Fork 31
Bugfix: Clamp Note.noteNumber to MIDI range (0-127) to prevent crashes #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,4 +162,21 @@ final class NoteTests: XCTestCase { | |
| let empty = NoteSet() | ||
| XCTAssertNil(empty.first) | ||
| } | ||
|
|
||
| func testClampNoteBounds() { | ||
| let bMinus3 = Note(.B, octave: -3) | ||
| XCTAssertEqual(bMinus3.noteNumber, 0) | ||
|
|
||
| let cFlatMinus3 = Note(.C, accidental: .flat, octave: -3) | ||
| XCTAssertEqual(cFlatMinus3.noteNumber, 0) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm following the spacing convention established in other tests in this file, where assertion statements |
||
| let a8 = Note(.A, octave: 8) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm following what appears to be a well established convention in the tests for identifiers referring to notes |
||
| XCTAssertEqual(a8.noteNumber, 127) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm following the spacing convention established in other tests in this file, where assertion statements |
||
| let gSharp8 = Note(.G, accidental: .sharp, octave: 8) | ||
| XCTAssertEqual(gSharp8.noteNumber, 127) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm following the spacing convention established in other tests in this file, where assertion statements |
||
| let c9 = Note(.C, octave: 9) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm following what appears to be a well established convention in the tests for identifiers referring to notes |
||
| XCTAssertEqual(c9.noteNumber, 127) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following the spacing convention established in other tests in this file, where assertion statements
are grouped with their supporting setup statements using blank lines. This convention
helps clarify the logical grouping and makes the test structure more readable.