File tree Expand file tree Collapse file tree 4 files changed +112
-35
lines changed
includes/RhythmGameUtilities/Enums
tests/RhythmGameUtilities Expand file tree Collapse file tree 4 files changed +112
-35
lines changed Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
+ #include < string>
4
+
3
5
namespace RhythmGameUtilities
4
6
{
5
7
6
8
enum Difficulty
7
9
{
8
10
11
+ // Easy Difficulty
9
12
Easy,
10
13
14
+ // Medium Difficulty
11
15
Medium,
12
16
17
+ // Hard Difficulty
13
18
Hard,
14
19
20
+ // Expert Difficulty
15
21
Expert
16
22
17
23
};
18
24
25
+ std::string ToString (Difficulty difficulty)
26
+ {
27
+ switch (difficulty)
28
+ {
29
+ case Easy:
30
+ return " Easy" ;
31
+ case Medium:
32
+ return " Medium" ;
33
+ case Hard:
34
+ return " Hard" ;
35
+ case Expert:
36
+ return " Expert" ;
37
+ }
38
+ }
39
+
19
40
} // namespace RhythmGameUtilities
Original file line number Diff line number Diff line change 5
5
namespace RhythmGameUtilities
6
6
{
7
7
8
- namespace NamedSection
8
+ enum NamedSection
9
9
{
10
- typedef std::string Type;
10
+ // / Song information
11
+ Song,
11
12
12
- // / <summary>
13
- // / Song information
14
- // / </summary>
15
- Type Song = " Song" ;
13
+ // / Track information used for syncing with music and notes like BPM
14
+ SyncTrack,
16
15
17
- // / <summary>
18
- // / Track information used for syncing with music and notes like BPM
19
- // / </summary>
20
- Type SyncTrack = " SyncTrack" ;
16
+ // / Track events
17
+ Events
18
+ };
21
19
22
- // / <summary>
23
- // / Track events
24
- // / </summary>
25
- Type Events = " Events" ;
26
-
27
- }; // namespace NamedSection
20
+ std::string ToString (NamedSection namedSection)
21
+ {
22
+ switch (namedSection)
23
+ {
24
+ case Song:
25
+ return " Song" ;
26
+ case SyncTrack:
27
+ return " SyncTrack" ;
28
+ case Events:
29
+ return " Events" ;
30
+ }
31
+ }
28
32
29
33
} // namespace RhythmGameUtilities
Original file line number Diff line number Diff line change 5
5
namespace RhythmGameUtilities
6
6
{
7
7
8
- namespace TypeCode
8
+ enum TypeCode
9
9
{
10
- typedef std::string Type;
11
10
12
- // / <summary>
13
- // / BPM Marker
14
- // / </summary>
15
- Type BPM = " B" ;
11
+ // / BPM Marker
12
+ BPM,
16
13
17
- // / <summary>
18
- // / Time Signature Marker
19
- // / </summary>
20
- Type TimeSignature = " TS" ;
14
+ // / Time Signature Marker
15
+ TimeSignature,
21
16
22
- // / <summary>
23
- // / Note Marker
24
- // / </summary>
25
- Type Note = " N" ;
17
+ // / Note Marker
18
+ Note,
26
19
27
- // / <summary>
28
- // / Event Marker
29
- // / </summary>
30
- Type Event = " E" ;
20
+ // / Event Marker
21
+ Event
31
22
32
- } // namespace TypeCode
23
+ };
24
+
25
+ std::string ToString (TypeCode typeCode)
26
+ {
27
+ switch (typeCode)
28
+ {
29
+ case BPM:
30
+ return " B" ;
31
+ case TimeSignature:
32
+ return " TS" ;
33
+ case Note:
34
+ return " N" ;
35
+ case Event:
36
+ return " E" ;
37
+ }
38
+ }
33
39
34
40
} // namespace RhythmGameUtilities
Original file line number Diff line number Diff line change
1
+ #include < cassert>
2
+ #include < iostream>
3
+
4
+ #include " RhythmGameUtilities/Enums/Difficulty.h"
5
+ #include " RhythmGameUtilities/Enums/NamedSection.h"
6
+ #include " RhythmGameUtilities/Enums/TypeCode.h"
7
+
8
+ using namespace RhythmGameUtilities ;
9
+
10
+ void testDifficulty ()
11
+ {
12
+ assert (ToString (Difficulty::Easy) == " Easy" );
13
+ assert (ToString (Difficulty::Medium) == " Medium" );
14
+ assert (ToString (Difficulty::Hard) == " Hard" );
15
+ assert (ToString (Difficulty::Expert) == " Expert" );
16
+
17
+ std::cout << " ." ;
18
+ }
19
+
20
+ void testNamedSection ()
21
+ {
22
+ assert (ToString (NamedSection::Song) == " Song" );
23
+ assert (ToString (NamedSection::SyncTrack) == " SyncTrack" );
24
+ assert (ToString (NamedSection::Events) == " Events" );
25
+
26
+ std::cout << " ." ;
27
+ }
28
+
29
+ void testTypeCode ()
30
+ {
31
+ assert (ToString (TypeCode::BPM) == " B" );
32
+ assert (ToString (TypeCode::TimeSignature) == " TS" );
33
+ assert (ToString (TypeCode::Note) == " N" );
34
+ assert (ToString (TypeCode::Event) == " E" );
35
+
36
+ std::cout << " ." ;
37
+ }
38
+
39
+ int main ()
40
+ {
41
+ testDifficulty ();
42
+ testNamedSection ();
43
+ testTypeCode ();
44
+
45
+ return 0 ;
46
+ }
You can’t perform that action at this time.
0 commit comments