File: wave.cpp

package info (click to toggle)
giada 0.15.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,700 kB
  • sloc: cpp: 30,043; sh: 1,056; makefile: 422; ansic: 1
file content (50 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <memory>
#include "../src/core/wave.h"
#include <catch.hpp>


using std::string;


TEST_CASE("Wave")
{
	static const int SAMPLE_RATE = 44100;
	static const int BUFFER_SIZE = 4096;
	static const int CHANNELS = 2;
	static const int BIT_DEPTH = 32;

	/* Each SECTION the TEST_CASE is executed from the start. Any code between 
	this comment and the first SECTION macro is exectuted before each SECTION. */


	SECTION("test allocation")
	{
		Wave wave;
		wave.alloc(BUFFER_SIZE, CHANNELS, SAMPLE_RATE, BIT_DEPTH, "path/to/sample.wav");

		SECTION("test basename")
		{
			REQUIRE(wave.getPath() == "path/to/sample.wav");
			REQUIRE(wave.getBasename() == "sample");
			REQUIRE(wave.getBasename(true) == "sample.wav");
		}

		SECTION("test path")
		{
			wave.setPath("path/is/now/different.mp3");

			REQUIRE(wave.getPath() == "path/is/now/different.mp3");

			wave.setPath("path/is/now/different.mp3", 5);

			REQUIRE(wave.getPath() == "path/is/now/different-5.mp3");
		}  

		SECTION("test change name")
		{
			REQUIRE(wave.getPath() == "path/to/sample.wav");
			REQUIRE(wave.getBasename() == "sample");
			REQUIRE(wave.getBasename(true) == "sample.wav");
		}
	}
}