<commit_before>//
//  AKDiskStreamerTests.swift
//  iOSTestSuite
//
//  Created by <NAME> on 6/28/18.
//  Copyright © 2018 AudioKit. All rights reserved.
//

import AudioKit
import XCTest

class AKDiskStreamerTests: AKTestCase {

    var streamer: AKDiskStreamer?

    func testDoNothing() {
        setupStreamer()
        AKTestMD5("d2b120199019b639d5a7e2b3463e9c97")
    }

    func testPlayback() {
        setupStreamer()
        afterStart = {
            self.loadFile()
            self.streamer?.play()
        }
        AKTestMD5("d8bf32699a72873551a44e0a2758a5da")
    }

    let testCompletionHandlerMD5 = "e561e0d540fe09b09f7e3399d09829f5"

    func testCompletionHandler() {
        streamer?.completionHandler = {
            self.streamer?.play()
        }
        afterStart = {
            self.loadFile()
            self.streamer?.play()
        }
        AKTestMD5(testCompletionHandlerMD5)
    }

    func testForwardLoop() {
        afterStart = {
            self.loadFile()
            self.streamer?.loopEnabled = true
            self.streamer?.play()
        }
        AKTestMD5(testCompletionHandlerMD5)
    }

    func testSlowdown() {
        afterStart = {
            self.loadFile()
            self.streamer?.rate = 0.5
            self.streamer?.play()
        }
        AKTestMD5("71f031bac4f9c935c8a8ddf653b02f7c")
    }

    func testSpeedup() {
        afterStart = {
            self.loadFile()
            self.streamer?.rate = 1.5
            self.streamer?.play()
        }
        AKTestMD5("347e2708deb5684ebf97817e3b72f279")
    }

    func testSeek() {
        afterStart = {
            self.loadFile()
            self.streamer?.play()
            self.streamer?.seek(to: 1_000)
        }
        AKTestMD5("c8da2c623a280eb9284bb41202d06d13")
    }

    func setupStreamer() {
        streamer = AKDiskStreamer()
        output = streamer
    }
    func loadFile() {
        if let path = Bundle.main.path(forResource: "sinechirp", ofType: "wav") {
            let url = URL(fileURLWithPath: path)
            let file = try! AKAudioFile(forReading: url)
            streamer?.load(file: file)
        } else {
            XCTFail("Could not load sinechirp.wav")
        }
    }

    override func setUp() {<commit_msg>Updating tests for @eljeff updates to disk streamer, @eljeff please verify<commit_after>//
//  AKDiskStreamerTests.swift
//  iOSTestSuite
//
//  Created by <NAME> on 6/28/18.
//  Copyright © 2018 AudioKit. All rights reserved.
//

import AudioKit
import XCTest

class AKDiskStreamerTests: AKTestCase {

    var streamer: AKDiskStreamer?

    func testDoNothing() {
        setupStreamer()
        AKTestMD5("d2b120199019b639d5a7e2b3463e9c97")
    }

    func testPlayback() {
        setupStreamer()
        afterStart = {
            self.loadFile()
            self.streamer?.play()
        }
        AKTestMD5("5d836377d0098d7c1e3624a94e86e03d")
    }

    let testCompletionHandlerMD5 = "5f306e81c0e36951a048aae9874e9b40"

    func testCompletionHandler() {
        streamer?.completionHandler = {
            self.streamer?.play()
        }
        afterStart = {
            self.loadFile()
            self.streamer?.play()
        }
        AKTestMD5(testCompletionHandlerMD5)
    }

    func testForwardLoop() {
        afterStart = {
            self.loadFile()
            self.streamer?.loopEnabled = true
            self.streamer?.play()
        }
        AKTestMD5(testCompletionHandlerMD5)
    }

    func testSlowdown() {
        afterStart = {
            self.loadFile()
            self.streamer?.rate = 0.5
            self.streamer?.play()
        }
        AKTestMD5("c1f8dcf69cd781fdc94dc9866660fd79")
    }

    func testSpeedup() {
        afterStart = {
            self.loadFile()
            self.streamer?.rate = 1.5
            self.streamer?.play()
        }
        AKTestMD5("4615ccfa3a8fc8872197d604d835f57e")
    }

    func testSeek() {
        afterStart = {
            self.loadFile()
            self.streamer?.play()
            self.streamer?.seek(to: 1_000)
        }
        AKTestMD5("e448e20b096fa6e341ba6a419b1b4760")
    }

    func setupStreamer() {
        streamer = AKDiskStreamer()
        output = streamer
    }
    func loadFile() {
        if let path = Bundle.main.path(forResource: "sinechirp", ofType: "wav") {
            let url = URL(fileURLWithPath: path)
            let file = try! AKAudioFile(forReading: url)
            streamer?.load(file: file)
        } else {
            XCTFail("Could not load sinechirp.wav")
        }
    }

    override func setUp() {
{'fraction_non_alphanumeric': 0.10284844531419873, 'fraction_numerical': 0.06740595781691672, 'mean_word_length': 1.8412600370599135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '238946', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1498, 'n_words': 236}