[DEV] add some test that not work and stabilize API

This commit is contained in:
Edouard DUPIN 2015-04-08 23:37:08 +02:00
parent fbca37b344
commit d227eb8f3d
29 changed files with 344 additions and 71 deletions

View File

@ -4,10 +4,8 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <audio/debug.h>
#include <audio/int16_16_t.h> #include <audio/int16_16_t.h>
#include <audio/debug.h>
audio::int16_16_t::int16_16_t(const audio::int8_8_t& _val) { audio::int16_16_t::int16_16_t(const audio::int8_8_t& _val) {
m_data = int16_t(_val.get()) << 8; m_data = int16_t(_val.get()) << 8;
@ -86,7 +84,7 @@ void audio::int16_16_t::set(int64_t _value, int32_t _flotingPointPosition) {
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_16_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_16_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":0.16="; _os << "[" << etk::to_string(_obj.get()) << ":0.15=";
_os << etk::to_string(double(_obj.get())/double(INT16_MAX)); _os << etk::to_string(double(_obj.get())/double(INT16_MAX));
_os << "]"; _os << "]";
return _os; return _os;

View File

@ -12,6 +12,13 @@
#include <audio/debug.h> #include <audio/debug.h>
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |BS| < 1.0 |
* +--+--------------------------------------------+
*/
class int16_16_t{ class int16_16_t{
private: private:
int16_t m_data; int16_t m_data;

View File

@ -52,7 +52,7 @@ audio::int16_32_t::int16_32_t(const audio::float_t& _val) {
m_data = int32_t(std::avg(float(INT16_MIN), m_data = int32_t(std::avg(float(INT16_MIN),
_val.get(), _val.get(),
float(INT16_MAX) float(INT16_MAX)
) * float(INT16_MAX) ) * float(INT16_MAX) * 2.0f
); );
} }
@ -60,7 +60,7 @@ audio::int16_32_t::int16_32_t(const audio::double_t& _val) {
m_data = int32_t(std::avg(double(INT16_MIN), m_data = int32_t(std::avg(double(INT16_MIN),
_val.get(), _val.get(),
double(INT16_MAX) double(INT16_MAX)
) * double(INT16_MAX) ) * double(INT16_MAX) * 2.0
); );
} }
@ -69,13 +69,13 @@ audio::int16_32_t::int16_32_t(int64_t _value, int32_t _flotingPointPosition) {
} }
void audio::int16_32_t::set(int64_t _value, int32_t _flotingPointPosition) { void audio::int16_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
int64_t val = _value << (15-_flotingPointPosition); int64_t val = _value << (16-_flotingPointPosition);
m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX)); m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX));
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_32_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_32_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":8.16="; _os << "[" << etk::to_string(_obj.get()) << ":7.16=";
_os << etk::to_string(double(_obj.get())/double(INT16_MAX)); _os << etk::to_string(double(_obj.get())/double(INT16_MAX)*0.5);
_os << "]"; _os << "]";
return _os; return _os;
} }

View File

@ -10,6 +10,13 @@
#define __AUDIO_TYPE_INT16_32_T_H__ #define __AUDIO_TYPE_INT16_32_T_H__
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |BS| > 1.0 | < 1.0 |
* +--+--------------------------------------------+-----------------------------------------------+
*/
class int16_32_t{ class int16_32_t{
private: private:
int32_t m_data; int32_t m_data;
@ -116,8 +123,8 @@ namespace audio {
* *= operator * *= operator
*****************************************************/ *****************************************************/
const int16_32_t& operator*= (const int16_32_t& _obj) { const int16_32_t& operator*= (const int16_32_t& _obj) {
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1<<14); int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1<<15);
m_data = int32_t(tmp >> 15); m_data = int32_t(tmp >> 16);
return *this; return *this;
} }
/* **************************************************** /* ****************************************************
@ -132,7 +139,7 @@ namespace audio {
* /= operator * /= operator
*****************************************************/ *****************************************************/
const int16_32_t& operator/= (const int16_32_t& _obj) { const int16_32_t& operator/= (const int16_32_t& _obj) {
int64_t tmp = (int64_t(m_data) << 15) / int64_t(_obj.m_data); int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
m_data = int32_t(tmp); m_data = int32_t(tmp);
return *this; return *this;
} }

View File

@ -69,7 +69,7 @@ audio::int24_24_t::int24_24_t(int64_t _value, int32_t _flotingPointPosition) {
} }
void audio::int24_24_t::set(int64_t _value, int32_t _flotingPointPosition) { void audio::int24_24_t::set(int64_t _value, int32_t _flotingPointPosition) {
int64_t val = _value << (24-_flotingPointPosition); int64_t val = _value << (23-_flotingPointPosition);
val = std::avg(int64_t(INT24_MIN), val, int64_t(INT24_MAX)); val = std::avg(int64_t(INT24_MIN), val, int64_t(INT24_MAX));
m_data[0] = (val & 0x000000ff); m_data[0] = (val & 0x000000ff);
m_data[1] = (val & 0x0000ff00) >> 8; m_data[1] = (val & 0x0000ff00) >> 8;
@ -91,7 +91,7 @@ int32_t audio::int24_24_t::get() const {
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int24_24_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int24_24_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":0.24="; _os << "[" << etk::to_string(_obj.get()) << ":0.23=";
_os << etk::to_string(double(_obj.get())/double(INT24_MAX)); _os << etk::to_string(double(_obj.get())/double(INT24_MAX));
_os << "]"; _os << "]";
return _os; return _os;

View File

@ -10,6 +10,13 @@
#define __AUDIO_TYPE_INT24_24_T_H__ #define __AUDIO_TYPE_INT24_24_T_H__
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |BS| < 1.0 |
* +--+--------------------------------------------------------------------+
*/
class int24_24_t { class int24_24_t {
private: private:
uint8_t m_data[3]; uint8_t m_data[3];

View File

@ -77,7 +77,7 @@ audio::int24_32_t::int24_32_t(const audio::float_t& _val) {
m_data = int32_t(std::avg(float(INT8_MIN), m_data = int32_t(std::avg(float(INT8_MIN),
_val.get(), _val.get(),
float(INT8_MAX) float(INT8_MAX)
) * float(INT24_MAX) ) * float(INT24_MAX) * 2.0f
); );
} }
@ -85,7 +85,7 @@ audio::int24_32_t::int24_32_t(const audio::double_t& _val) {
m_data = int32_t(std::avg(-1.0, m_data = int32_t(std::avg(-1.0,
_val.get(), _val.get(),
1.0 1.0
) * double(INT24_MAX) ) * double(INT24_MAX) * 2.0
); );
} }
@ -100,8 +100,8 @@ void audio::int24_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
std::ostream& audio::operator <<(std::ostream& _os, const audio::int24_32_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int24_32_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << "8:24="; _os << "[" << etk::to_string(_obj.get()) << "7:24=";
_os << etk::to_string(double(_obj.get())/double(INT24_MAX)); _os << etk::to_string(double(_obj.get())/double(INT24_MAX)*0.5);
_os << "]"; _os << "]";
return _os; return _os;
} }

View File

@ -10,6 +10,13 @@
#define __AUDIO_TYPE_INT24_32_T_H__ #define __AUDIO_TYPE_INT24_32_T_H__
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |BS| > 1.0 | < 1.0 |
* +--+--------------------+-----------------------------------------------------------------------+
*/
class int24_32_t { class int24_32_t {
private: private:
int32_t m_data; int32_t m_data;
@ -117,7 +124,7 @@ namespace audio {
*****************************************************/ *****************************************************/
const int24_32_t& operator*= (const int24_32_t& _obj) { const int24_32_t& operator*= (const int24_32_t& _obj) {
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data); int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
m_data = int32_t(tmp >> 8); m_data = int32_t(tmp >> 24);
return *this; return *this;
} }
/* **************************************************** /* ****************************************************

View File

@ -90,7 +90,7 @@ audio::int32_32_t::int32_32_t(const audio::float_t& _val) {
} }
audio::int32_32_t::int32_32_t(const audio::double_t& _val) { audio::int32_32_t::int32_32_t(const audio::double_t& _val) {
m_data = int16_t(std::avg(-1.0, m_data = int32_t(std::avg(-1.0,
_val.get(), _val.get(),
1.0 1.0
) * double(INT32_MAX) ) * double(INT32_MAX)
@ -102,13 +102,13 @@ audio::int32_32_t::int32_32_t(int64_t _value, int32_t _flotingPointPosition) {
} }
void audio::int32_32_t::set(int64_t _value, int32_t _flotingPointPosition) { void audio::int32_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
int64_t val = _value << (32-_flotingPointPosition); int64_t val = _value << (31-_flotingPointPosition);
m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX)); m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX));
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_32_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_32_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":0.32="; _os << "[" << etk::to_string(_obj.get()) << ":0.31=";
_os << etk::to_string(double(_obj.get())/double(INT16_MAX)); _os << etk::to_string(double(_obj.get())/double(INT16_MAX));
_os << "]"; _os << "]";
return _os; return _os;

View File

@ -12,6 +12,11 @@
#include <audio/debug.h> #include <audio/debug.h>
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*/
class int32_32_t { class int32_32_t {
private: private:
int32_t m_data; int32_t m_data;
@ -118,8 +123,8 @@ namespace audio {
* *= operator * *= operator
*****************************************************/ *****************************************************/
const int32_32_t& operator*= (const int32_32_t& _obj) { const int32_32_t& operator*= (const int32_32_t& _obj) {
int64_t tmp = int32_t(m_data) * int32_t(_obj.m_data); int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1LL<<30);
m_data = int32_t(tmp >> 32); m_data = int32_t(tmp >> 31);
return *this; return *this;
} }
/* **************************************************** /* ****************************************************
@ -134,7 +139,7 @@ namespace audio {
* /= operator * /= operator
*****************************************************/ *****************************************************/
const int32_32_t& operator/= (const int32_32_t& _obj) { const int32_32_t& operator/= (const int32_32_t& _obj) {
int64_t tmp = (int64_t(m_data) << 32) / int32_t(_obj.m_data); int64_t tmp = (int64_t(m_data) << 31) / int64_t(_obj.m_data);
m_data = int32_t(tmp); m_data = int32_t(tmp);
return *this; return *this;
} }

View File

@ -69,7 +69,7 @@ audio::int32_64_t::int32_64_t(const audio::float_t& _val) {
m_data = int64_t(std::avg(float(INT32_MIN), m_data = int64_t(std::avg(float(INT32_MIN),
_val.get(), _val.get(),
float(INT32_MAX) float(INT32_MAX)
) * float(INT32_MAX) ) * float(INT32_MAX) * 2.0f
); );
} }
@ -77,7 +77,7 @@ audio::int32_64_t::int32_64_t(const audio::double_t& _val) {
m_data = int64_t(std::avg(double(INT32_MIN), m_data = int64_t(std::avg(double(INT32_MIN),
_val.get(), _val.get(),
double(INT32_MIN) double(INT32_MIN)
) * double(INT32_MAX) ) * double(INT32_MAX) * 2.0
); );
} }
@ -92,8 +92,8 @@ void audio::int32_64_t::set(int64_t _value, int32_t _flotingPointPosition) {
std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_64_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_64_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":32.32="; _os << "[" << etk::to_string(_obj.get()) << ":31.32=";
_os << etk::to_string(double(_obj.get())/double(INT32_MAX)); _os << etk::to_string(double(_obj.get())/double(INT32_MAX)*0.5);
_os << "]"; _os << "]";
return _os; return _os;
} }

View File

@ -116,8 +116,8 @@ namespace audio {
* *= operator * *= operator
*****************************************************/ *****************************************************/
const int32_64_t& operator*= (const int32_64_t& _obj) { const int32_64_t& operator*= (const int32_64_t& _obj) {
int64_t tmp = m_data>>12 * _obj.m_data>>12; int64_t tmp = m_data * _obj.m_data;
m_data = int64_t(tmp >> 8); m_data = int64_t(tmp >> 32);
return *this; return *this;
} }
/* **************************************************** /* ****************************************************
@ -132,7 +132,7 @@ namespace audio {
* /= operator * /= operator
*****************************************************/ *****************************************************/
const int32_64_t& operator/= (const int32_64_t& _obj) { const int32_64_t& operator/= (const int32_64_t& _obj) {
int64_t tmp = (int64_t(m_data) << 16) / int16_t(_obj.m_data); int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data) + (1LL<<15);
m_data = int64_t(tmp)<<16; m_data = int64_t(tmp)<<16;
return *this; return *this;
} }

View File

@ -98,13 +98,13 @@ audio::int64_64_t::int64_64_t(int64_t _value, int32_t _flotingPointPosition) {
} }
void audio::int64_64_t::set(int64_t _value, int32_t _flotingPointPosition) { void audio::int64_64_t::set(int64_t _value, int32_t _flotingPointPosition) {
int64_t val = _value << (64-_flotingPointPosition); int64_t val = _value << (63-_flotingPointPosition);
m_data = std::avg(int64_t(INT64_MIN), val, int64_t(INT64_MAX)); m_data = std::avg(int64_t(INT64_MIN), val, int64_t(INT64_MAX));
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int64_64_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int64_64_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":0.64="; _os << "[" << etk::to_string(_obj.get()) << ":0.63=";
_os << etk::to_string(double(_obj.get())/double(INT64_MAX)); _os << etk::to_string(double(_obj.get())/double(INT64_MAX));
_os << "]"; _os << "]";
return _os; return _os;

View File

@ -118,7 +118,7 @@ namespace audio {
* *= operator * *= operator
*****************************************************/ *****************************************************/
const int64_64_t& operator*= (const int64_64_t& _obj) { const int64_64_t& operator*= (const int64_64_t& _obj) {
int16_t tmp = (m_data >> 32) * (_obj.m_data >> 32); int16_t tmp = (m_data >> 31) * (_obj.m_data >> 32);
m_data = tmp; m_data = tmp;
return *this; return *this;
} }
@ -134,7 +134,7 @@ namespace audio {
* /= operator * /= operator
*****************************************************/ *****************************************************/
const int64_64_t& operator/= (const int64_64_t& _obj) { const int64_64_t& operator/= (const int64_64_t& _obj) {
int64_t tmp = (m_data << 32) / (_obj.m_data>>32); int64_t tmp = (m_data << 31) / (_obj.m_data>>32);
m_data = tmp; m_data = tmp;
return *this; return *this;
} }

View File

@ -77,7 +77,7 @@ audio::int8_16_t::int8_16_t(const audio::float_t& _val) {
m_data = int16_t(std::avg(float(INT8_MIN), m_data = int16_t(std::avg(float(INT8_MIN),
_val.get(), _val.get(),
float(INT8_MAX) float(INT8_MAX)
) * float(INT8_MAX) ) * float(INT8_MAX) * 2.0f
); );
} }
@ -85,7 +85,7 @@ audio::int8_16_t::int8_16_t(const audio::double_t& _val) {
m_data = int16_t(std::avg(double(INT8_MIN), m_data = int16_t(std::avg(double(INT8_MIN),
_val.get(), _val.get(),
double(INT8_MAX) double(INT8_MAX)
) * double(INT8_MAX) ) * double(INT8_MAX) * 2.0
); );
} }
@ -100,8 +100,8 @@ void audio::int8_16_t::set(int64_t _value, int32_t _flotingPointPosition) {
std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_16_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_16_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":8.8="; _os << "[" << etk::to_string(_obj.get()) << ":7.8=";
_os << etk::to_string(double(_obj.get())/double(INT8_MAX)); _os << etk::to_string(double(_obj.get())/double(INT8_MAX)*0.5);
_os << "]"; _os << "]";
return _os; return _os;
} }

View File

@ -10,6 +10,13 @@
#define __AUDIO_TYPE_INT8_16_T_H__ #define __AUDIO_TYPE_INT8_16_T_H__
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |BS| > 1.0 | < 1.0 |
* +--+--------------------------------------------+
*/
class int8_16_t { class int8_16_t {
private: private:
int16_t m_data; int16_t m_data;

View File

@ -100,13 +100,13 @@ audio::int8_8_t::int8_8_t(int64_t _value, int32_t _flotingPointPosition) {
} }
void audio::int8_8_t::set(int64_t _value, int32_t _flotingPointPosition) { void audio::int8_8_t::set(int64_t _value, int32_t _flotingPointPosition) {
int64_t val = _value << (8-_flotingPointPosition); int64_t val = _value << (7-_flotingPointPosition);
m_data = std::avg(int64_t(INT8_MIN), val, int64_t(INT8_MAX)); m_data = std::avg(int64_t(INT8_MIN), val, int64_t(INT8_MAX));
} }
std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_8_t& _obj) { std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_8_t& _obj) {
_os << "[" << etk::to_string(_obj.get()) << ":0.8="; _os << "[" << etk::to_string(_obj.get()) << ":0.7=";
_os << etk::to_string(double(_obj.get())/double(INT8_MAX)); _os << etk::to_string(double(_obj.get())/double(INT8_MAX));
_os << "]"; _os << "]";
return _os; return _os;

View File

@ -12,6 +12,11 @@
#include <audio/debug.h> #include <audio/debug.h>
namespace audio { namespace audio {
/**
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*/
class int8_8_t { class int8_8_t {
private: private:
int8_t m_data; int8_t m_data;
@ -119,7 +124,7 @@ namespace audio {
*****************************************************/ *****************************************************/
const int8_8_t& operator*= (const int8_8_t& _obj) { const int8_8_t& operator*= (const int8_8_t& _obj) {
int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data); int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data);
m_data = int8_t(tmp >> 8); m_data = int8_t(tmp >> 7);
return *this; return *this;
} }
/* **************************************************** /* ****************************************************
@ -134,7 +139,7 @@ namespace audio {
* /= operator * /= operator
*****************************************************/ *****************************************************/
const int8_8_t& operator/= (const int8_8_t& _obj) { const int8_8_t& operator/= (const int8_8_t& _obj) {
int16_t tmp = (int16_t(m_data) << 8) / int16_t(_obj.m_data); int16_t tmp = (int16_t(m_data) << 7) / int16_t(_obj.m_data);
m_data = int8_t(tmp); m_data = int8_t(tmp);
return *this; return *this;
} }

View File

@ -13,8 +13,13 @@ def create(target):
'test/debug.cpp', 'test/debug.cpp',
'test/main.cpp', 'test/main.cpp',
'test/base.cpp', 'test/base.cpp',
'test/test_int8_8.cpp',
'test/test_int8_16.cpp',
'test/test_int16_16.cpp', 'test/test_int16_16.cpp',
'test/test_int16_32.cpp', 'test/test_int16_32.cpp',
'test/test_int32_32.cpp',
'test/test_int32_64.cpp',
'test/test_int64_64.cpp',
'test/test_float.cpp' 'test/test_float.cpp'
]) ])
myModule.add_module_depend(['audio', 'gtest']) myModule.add_module_depend(['audio', 'gtest'])

View File

@ -11,15 +11,15 @@
TEST(TestBase, type_int8_8_t) { TEST(TestBase, type_int8_8_t) {
audio::int8_8_t typeBase(16, 8); audio::int8_8_t typeBase(16, 7);
EXPECT_EQ(typeBase.get(), 16); EXPECT_EQ(typeBase.get(), 16);
typeBase.set(INT8_MIN, 8); typeBase.set(INT8_MIN, 7);
EXPECT_EQ(typeBase.get(), INT8_MIN); EXPECT_EQ(typeBase.get(), INT8_MIN);
typeBase.set(INT8_MAX, 8); typeBase.set(INT8_MAX, 7);
EXPECT_EQ(typeBase.get(), INT8_MAX); EXPECT_EQ(typeBase.get(), INT8_MAX);
typeBase.set(INT8_MAX+200, 8); typeBase.set(INT8_MAX+200, 7);
EXPECT_EQ(typeBase.get(), INT8_MAX); EXPECT_EQ(typeBase.get(), INT8_MAX);
typeBase.set(INT8_MIN-200, 8); typeBase.set(INT8_MIN-200, 7);
EXPECT_EQ(typeBase.get(), INT8_MIN); EXPECT_EQ(typeBase.get(), INT8_MIN);
typeBase.set(-125); typeBase.set(-125);
EXPECT_EQ(typeBase.get(), -125); EXPECT_EQ(typeBase.get(), -125);
@ -42,15 +42,15 @@ TEST(TestBase, type_int8_16_t) {
TEST(TestBase, type_int16_16_t) { TEST(TestBase, type_int16_16_t) {
audio::int16_16_t typeBase(16, 16); audio::int16_16_t typeBase(16, 15);
EXPECT_EQ(typeBase.get(), 16); EXPECT_EQ(typeBase.get(), 16);
typeBase.set(INT16_MIN, 16); typeBase.set(INT16_MIN, 15);
EXPECT_EQ(typeBase.get(), INT16_MIN); EXPECT_EQ(typeBase.get(), INT16_MIN);
typeBase.set(INT16_MAX, 16); typeBase.set(INT16_MAX, 15);
EXPECT_EQ(typeBase.get(), INT16_MAX); EXPECT_EQ(typeBase.get(), INT16_MAX);
typeBase.set(INT16_MAX+200, 16); typeBase.set(INT16_MAX+200, 15);
EXPECT_EQ(typeBase.get(), INT16_MAX); EXPECT_EQ(typeBase.get(), INT16_MAX);
typeBase.set(INT16_MIN-200, 16); typeBase.set(INT16_MIN-200, 15);
EXPECT_EQ(typeBase.get(), INT16_MIN); EXPECT_EQ(typeBase.get(), INT16_MIN);
typeBase.set(-250); typeBase.set(-250);
EXPECT_EQ(typeBase.get(), -250); EXPECT_EQ(typeBase.get(), -250);
@ -73,15 +73,15 @@ TEST(TestBase, type_int16_32_t) {
TEST(TestBase, type_int24_24_t) { TEST(TestBase, type_int24_24_t) {
audio::int24_24_t typeBase(16, 24); audio::int24_24_t typeBase(16, 23);
EXPECT_EQ(typeBase.get(), 16); EXPECT_EQ(typeBase.get(), 16);
typeBase.set(INT24_MIN, 24); typeBase.set(INT24_MIN, 23);
EXPECT_EQ(typeBase.get(), INT24_MIN); EXPECT_EQ(typeBase.get(), INT24_MIN);
typeBase.set(INT24_MAX, 24); typeBase.set(INT24_MAX, 23);
EXPECT_EQ(typeBase.get(), INT24_MAX); EXPECT_EQ(typeBase.get(), INT24_MAX);
typeBase.set(int64_t(INT24_MAX)+200, 24); typeBase.set(int64_t(INT24_MAX)+200, 23);
EXPECT_EQ(typeBase.get(), INT24_MAX); EXPECT_EQ(typeBase.get(), INT24_MAX);
typeBase.set(int64_t(INT24_MIN)-200, 24); typeBase.set(int64_t(INT24_MIN)-200, 23);
EXPECT_EQ(typeBase.get(), INT24_MIN); EXPECT_EQ(typeBase.get(), INT24_MIN);
typeBase.set(-250); typeBase.set(-250);
EXPECT_EQ(typeBase.get(), -250); EXPECT_EQ(typeBase.get(), -250);
@ -104,15 +104,15 @@ TEST(TestBase, type_int24_32_t) {
} }
TEST(TestBase, type_int32_32_t) { TEST(TestBase, type_int32_32_t) {
audio::int32_32_t typeBase(16, 32); audio::int32_32_t typeBase(16, 31);
EXPECT_EQ(typeBase.get(), 16); EXPECT_EQ(typeBase.get(), 16);
typeBase.set(INT32_MIN, 32); typeBase.set(INT32_MIN, 31);
EXPECT_EQ(typeBase.get(), INT32_MIN); EXPECT_EQ(typeBase.get(), INT32_MIN);
typeBase.set(INT32_MAX, 32); typeBase.set(INT32_MAX, 31);
EXPECT_EQ(typeBase.get(), INT32_MAX); EXPECT_EQ(typeBase.get(), INT32_MAX);
typeBase.set(int64_t(INT32_MAX)+200, 32); typeBase.set(int64_t(INT32_MAX)+200, 31);
EXPECT_EQ(typeBase.get(), INT32_MAX); EXPECT_EQ(typeBase.get(), INT32_MAX);
typeBase.set(int64_t(INT32_MIN)-200, 32); typeBase.set(int64_t(INT32_MIN)-200, 31);
EXPECT_EQ(typeBase.get(), INT32_MIN); EXPECT_EQ(typeBase.get(), INT32_MIN);
typeBase.set(-250); typeBase.set(-250);
EXPECT_EQ(typeBase.get(), -250); EXPECT_EQ(typeBase.get(), -250);
@ -130,11 +130,11 @@ TEST(TestBase, type_int32_64_t) {
} }
TEST(TestBase, type_int64_64_t) { TEST(TestBase, type_int64_64_t) {
audio::int64_64_t typeBase(16, 64); audio::int64_64_t typeBase(16, 63);
EXPECT_EQ(typeBase.get(), 16); EXPECT_EQ(typeBase.get(), 16);
typeBase.set(INT64_MIN, 64); typeBase.set(INT64_MIN, 63);
EXPECT_EQ(typeBase.get(), INT64_MIN); EXPECT_EQ(typeBase.get(), INT64_MIN);
typeBase.set(INT64_MAX, 64); typeBase.set(INT64_MAX, 63);
EXPECT_EQ(typeBase.get(), INT64_MAX); EXPECT_EQ(typeBase.get(), INT64_MAX);
typeBase.set(-250); typeBase.set(-250);
EXPECT_EQ(typeBase.get(), -250); EXPECT_EQ(typeBase.get(), -250);

0
test/test_double.cpp Normal file
View File

View File

@ -22,11 +22,8 @@ TEST(TestInt16_16, basicOperator) {
out *= typeBase; out *= typeBase;
EXPECT_EQ(out.get(), 0); EXPECT_EQ(out.get(), 0);
out = audio::float_t(0.3); out = audio::float_t(0.3);
APPL_INFO(" data = " << out);
out += audio::float_t(0.3); out += audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.6)).get()); EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3); out *= audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.18)).get()); EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.18)).get());
} }

View File

@ -15,7 +15,7 @@ TEST(TestInt16_32, basicOperator) {
audio::int16_32_t out(1, 0); audio::int16_32_t out(1, 0);
APPL_INFO(" data = " << out); APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), ((1<<15))); EXPECT_EQ(out.get(), ((1<<16)));
out *= 16; out *= 16;
APPL_INFO(" data = " << out); APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16); EXPECT_EQ(out.get(), 16);

38
test/test_int24_32.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt24_32, basicOperator) {
audio::int24_32_t typeBase(16);
audio::int24_32_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), ((1<<16)));
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::float_t(0.3);
APPL_INFO(" data = " << out);
out += audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int24_32_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int24_32_t(audio::float_t(0.18)).get());
}

38
test/test_int32_32.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt32_32, basicOperator) {
audio::int32_32_t typeBase(16);
audio::int32_32_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), INT32_MAX);
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::double_t(0.3);
APPL_INFO(" data = " << out);
out += audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int32_32_t(audio::double_t(0.6)).get());
out *= audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int32_32_t(audio::double_t(0.18)).get());
}

38
test/test_int32_64.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt32_64, basicOperator) {
audio::int32_64_t typeBase(16);
audio::int32_64_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), (int64_t(INT32_MAX)+1)*2);
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::double_t(0.3);
APPL_INFO(" data = " << out);
out += audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int32_64_t(audio::double_t(0.6)).get());
out *= audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int32_64_t(audio::double_t(0.18)).get());
}

38
test/test_int64_64.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt64_64, basicOperator) {
audio::int64_64_t typeBase(16);
audio::int64_64_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), INT64_MAX);
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::double_t(0.3);
APPL_INFO(" data = " << out);
out += audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int64_64_t(audio::double_t(0.6)).get());
out *= audio::double_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int64_64_t(audio::double_t(0.18)).get());
}

38
test/test_int8_16.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt8_16, basicOperator) {
audio::int8_16_t typeBase(16);
audio::int8_16_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), ((1<<16)));
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::float_t(0.3);
APPL_INFO(" data = " << out);
out += audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int8_16_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int8_16_t(audio::float_t(0.18)).get());
}

38
test/test_int8_8.cpp Normal file
View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt8_8, basicOperator) {
audio::int8_8_t typeBase(16);
audio::int8_8_t out(1, 0);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), ((1<<16)));
out *= 16;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 16);
out = 1;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 1);
out *= typeBase;
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), 0);
out = audio::float_t(0.3);
APPL_INFO(" data = " << out);
out += audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int8_8_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int8_8_t(audio::float_t(0.18)).get());
}