23 lines
713 B
Swift
23 lines
713 B
Swift
import XCTest
|
|
@testable import DuooomiBleSDK
|
|
|
|
final class PlayModeTests: XCTestCase {
|
|
func testRawValues() {
|
|
XCTAssertEqual(PlayMode.single.rawValue, 0)
|
|
XCTAssertEqual(PlayMode.loop.rawValue, 1)
|
|
}
|
|
|
|
func testInitFromRawValue() {
|
|
XCTAssertEqual(PlayMode(rawValue: 0), .single)
|
|
XCTAssertEqual(PlayMode(rawValue: 1), .loop)
|
|
XCTAssertNil(PlayMode(rawValue: 2))
|
|
}
|
|
|
|
func testCodableRoundTrip() throws {
|
|
let data = try JSONEncoder().encode(PlayMode.loop)
|
|
XCTAssertEqual(String(data: data, encoding: .utf8), "1")
|
|
let decoded = try JSONDecoder().decode(PlayMode.self, from: Data("0".utf8))
|
|
XCTAssertEqual(decoded, .single)
|
|
}
|
|
}
|