File tree Expand file tree Collapse file tree 4 files changed +44
-6
lines changed
main/java/cz/koca2000/nbs4j
test/java/cz/koca2000/nbs4j/test Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 66
77 <groupId >cz.koca2000</groupId >
88 <artifactId >NBS4j</artifactId >
9- <version >1.1</version >
9+ <version >1.1.1 </version >
1010
1111 <properties >
1212 <maven .compiler.source>8</maven .compiler.source>
Original file line number Diff line number Diff line change @@ -341,11 +341,11 @@ public int getSongLength() {
341341 * @return tick number if there is any note or tempo change left; otherwise, -1
342342 */
343343 public int getNextNonEmptyTick (int fromTick ){
344- NavigableSet < Integer > subset = nonEmptyTicks .tailSet (fromTick , false );
345- if (subset . size () == 0 )
344+ Integer tick = nonEmptyTicks .higher (fromTick );
345+ if (tick == null )
346346 return -1 ;
347347
348- return subset . first () ;
348+ return tick ;
349349 }
350350
351351 /**
@@ -356,7 +356,7 @@ public int getNextNonEmptyTick(int fromTick){
356356 public float getTempo (int tick ){
357357 if (tempoChanges .size () == 0 )
358358 return 10 ;
359- return tempoChanges .floorKey (tick );
359+ return tempoChanges .floorEntry (tick ). getValue ( );
360360 }
361361
362362 /**
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ static void prepareSong(){
4040 .setName ("Custom Instrument 1" )
4141 .setFileName ("file/name" )
4242 .setKey (10 )
43- .setShouldPressKey (true ));
43+ .setShouldPressKey (true ))
44+ .setTempoChange (-1 , 8.0f );
4445 originalSong .freezeSong ();
4546 }
4647
@@ -164,6 +165,14 @@ void customInstrumentPressKey(NBSVersion nbsVersion){
164165 }
165166 }
166167
168+ @ ParameterizedTest
169+ @ EnumSource
170+ void tempo (NBSVersion nbsVersion ){
171+ Song savedSong = saveAndLoad (originalSong , nbsVersion );
172+
173+ assertEquals (originalSong .getTempo (0 ), savedSong .getTempo (0 ));
174+ }
175+
167176 private static Song saveAndLoad (Song song , NBSVersion nbsVersion ){
168177 ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
169178 song .save (nbsVersion , outputStream );
Original file line number Diff line number Diff line change 1+ package cz .koca2000 .nbs4j .test ;
2+
3+ import cz .koca2000 .nbs4j .Note ;
4+ import cz .koca2000 .nbs4j .Song ;
5+ import org .junit .jupiter .api .Assertions ;
6+ import org .junit .jupiter .api .Test ;
7+
8+ import static org .junit .jupiter .api .Assertions .assertEquals ;
9+
10+ public class SongTests {
11+
12+ @ Test
13+ void songTempo (){
14+ Song song = new Song ()
15+ .setTempoChange (-1 , 5 );
16+
17+ assertEquals (5 , song .getTempo (-1 ));
18+ assertEquals (5 , song .getTempo (0 ));
19+ }
20+
21+ @ Test
22+ void songNextTick (){
23+ Song song = new Song ()
24+ .setLayersCount (1 )
25+ .setNote (5 , 0 , new Note ());
26+
27+ assertEquals (5 , song .getNextNonEmptyTick (0 ));
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments