[DEV] continue debug

This commit is contained in:
Edouard DUPIN 2015-04-09 23:20:58 +02:00
parent d227eb8f3d
commit 96e875699f
32 changed files with 2392 additions and 245 deletions

View File

@ -57,7 +57,7 @@ audio::double_t::double_t(int64_t _value, int32_t _flotingPointPosition) {
}
void audio::double_t::set(int64_t _value, int32_t _flotingPointPosition) {
m_data = double(_value << (32-_flotingPointPosition)) / double(INT32_MAX);
m_data = double(_value << (31-_flotingPointPosition)) / (double(INT32_MAX)+1.0);
}

View File

@ -151,7 +151,7 @@ namespace audio {
}
double_t operator++(int _unused) {
double_t result(m_data);
result.m_data += 1.0f;
m_data += 1.0f;
return result;
}
/* ****************************************************
@ -163,7 +163,7 @@ namespace audio {
}
double_t operator--(int _unused) {
double_t result(m_data);
result.m_data -= 1.0f;
m_data -= 1.0f;
return result;
}
};

View File

@ -57,7 +57,7 @@ audio::float_t::float_t(int64_t _value, int32_t _flotingPointPosition) {
}
void audio::float_t::set(int64_t _value, int32_t _flotingPointPosition) {
m_data = float(_value << (32-_flotingPointPosition)) / float(INT32_MAX);
m_data = float(_value << (31-_flotingPointPosition)) / (float(INT32_MAX)+1.0f);
}
std::ostream& audio::operator <<(std::ostream& _os, const audio::float_t& _obj) {

View File

@ -151,7 +151,7 @@ namespace audio {
}
float_t operator++(int _unused) {
float_t result(m_data);
result.m_data += 1.0f;
m_data += 1.0f;
return result;
}
/* ****************************************************
@ -163,7 +163,7 @@ namespace audio {
}
float_t operator--(int _unused) {
float_t result(m_data);
result.m_data -= 1.0f;
m_data -= 1.0f;
return result;
}
};

View File

@ -15,7 +15,7 @@ audio::int16_16_t::int16_16_t(const audio::int8_16_t& _val) {
m_data = std::avg(int16_t(INT8_MIN),
_val.get(),
int16_t(INT8_MAX)
) << 8;
) << 7;
}
audio::int16_16_t::int16_16_t(const audio::int16_16_t& _val) {
@ -24,7 +24,7 @@ audio::int16_16_t::int16_16_t(const audio::int16_16_t& _val) {
audio::int16_16_t::int16_16_t(const audio::int16_32_t& _val) {
m_data = int16_t(std::avg(int32_t(INT16_MIN),
_val.get(),
_val.get() >> 1,
int32_t(INT16_MAX)
)
);
@ -36,7 +36,7 @@ audio::int16_16_t::int16_16_t(const audio::int24_24_t& _val) {
audio::int16_16_t::int16_16_t(const audio::int24_32_t& _val) {
m_data = int16_t(std::avg(int32_t(INT24_MIN),
_val.get(),
_val.get() >> 1,
int32_t(INT24_MAX)
) >> 8
);
@ -48,29 +48,29 @@ audio::int16_16_t::int16_16_t(const audio::int32_32_t& _val) {
audio::int16_16_t::int16_16_t(const audio::int32_64_t& _val) {
m_data = int16_t(std::avg(int64_t(INT32_MIN),
_val.get(),
_val.get() >> 1,
int64_t(INT32_MAX)
) >> 16
);
}
audio::int16_16_t::int16_16_t(const audio::int64_64_t& _val) {
m_data = int16_t(_val.get() >> 56);
m_data = int16_t(_val.get() >> 48);
}
audio::int16_16_t::int16_16_t(const audio::float_t& _val) {
m_data = int16_t(std::avg(-1.0f,
_val.get(),
1.0f
) * float(INT16_MAX)
0.999969482f
) * (float(INT16_MAX)+1)
);
}
audio::int16_16_t::int16_16_t(const audio::double_t& _val) {
m_data = int16_t(std::avg(-1.0,
_val.get(),
1.0
) * double(INT16_MAX)
0.999969482
) * (double(INT16_MAX)+1)
);
}
@ -85,7 +85,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) {
_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)+1));
_os << "]";
return _os;
}

View File

@ -125,7 +125,7 @@ namespace audio {
* *= operator
*****************************************************/
const int16_16_t& operator*= (const int16_16_t& _obj) {
int32_t tmp = int32_t(m_data) * int32_t(_obj.m_data) + (1<<14);
int32_t tmp = int32_t(m_data) * int32_t(_obj.m_data);
m_data = int16_t(tmp >> 15);
return *this;
}

View File

@ -9,7 +9,7 @@
audio::int16_32_t::int16_32_t(const audio::int8_8_t& _val) {
m_data = int32_t(_val.get()) << 8;
m_data = int32_t(_val.get()) << 9;
}
audio::int16_32_t::int16_32_t(const audio::int8_16_t& _val) {
@ -17,7 +17,7 @@ audio::int16_32_t::int16_32_t(const audio::int8_16_t& _val) {
}
audio::int16_32_t::int16_32_t(const audio::int16_16_t& _val) {
m_data = _val.get();
m_data = _val.get() << 1;
}
audio::int16_32_t::int16_32_t(const audio::int16_32_t& _val) {
@ -25,15 +25,15 @@ audio::int16_32_t::int16_32_t(const audio::int16_32_t& _val) {
}
audio::int16_32_t::int16_32_t(const audio::int24_24_t& _val) {
m_data = int32_t(_val.get() >> 8);
m_data = int32_t(_val.get() >> 7);
}
audio::int16_32_t::int16_32_t(const audio::int24_32_t& _val) {
m_data = int32_t(_val.get() >> 8);;
m_data = int32_t(_val.get() >> 8);
}
audio::int16_32_t::int16_32_t(const audio::int32_32_t& _val) {
m_data = int32_t(_val.get() >> 16);
m_data = int32_t(_val.get() >> 15);
}
audio::int16_32_t::int16_32_t(const audio::int32_64_t& _val) {
@ -45,14 +45,14 @@ audio::int16_32_t::int16_32_t(const audio::int32_64_t& _val) {
}
audio::int16_32_t::int16_32_t(const audio::int64_64_t& _val) {
m_data = int32_t(_val.get() >> 56);
m_data = int32_t(_val.get() >> 47);
}
audio::int16_32_t::int16_32_t(const audio::float_t& _val) {
m_data = int32_t(std::avg(float(INT16_MIN),
_val.get(),
float(INT16_MAX)
) * float(INT16_MAX) * 2.0f
) * (float(INT16_MAX) * 2.0f+1.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),
_val.get(),
double(INT16_MAX)
) * double(INT16_MAX) * 2.0
) * (double(INT16_MAX) * 2.0+1.0)
);
}

View File

@ -160,7 +160,7 @@ namespace audio {
}
int16_32_t operator++(int _unused) {
int16_32_t result(m_data);
result.m_data += (1<<16);
m_data += (1<<16);
return result;
}
/* ****************************************************
@ -172,7 +172,7 @@ namespace audio {
}
int16_32_t operator--(int _unused) {
int16_32_t result(m_data);
result.m_data -= (1<<16);
m_data -= (1<<16);
return result;
}
};

View File

@ -4,14 +4,14 @@
* @license APACHE v2.0 (see license file)
*/
#include <audio/debug.h>
#include <audio/int24_24_t.h>
#include <audio/debug.h>
audio::int24_24_t::int24_24_t(const audio::int8_8_t& _val) {
int32_t val = _val.get();
set(int32_t(val), 8);
set(int32_t(val), 7);
}
audio::int24_24_t::int24_24_t(const audio::int8_16_t& _val) {
@ -21,7 +21,7 @@ audio::int24_24_t::int24_24_t(const audio::int8_16_t& _val) {
audio::int24_24_t::int24_24_t(const audio::int16_16_t& _val) {
int32_t val = _val.get();
set(int32_t(val), 16);
set(int32_t(val), 15);
}
audio::int24_24_t::int24_24_t(const audio::int16_32_t& _val) {
int32_t val = _val.get();
@ -35,12 +35,12 @@ audio::int24_24_t::int24_24_t(const audio::int24_24_t& _val) {
}
audio::int24_24_t::int24_24_t(const audio::int24_32_t& _val) {
set(int32_t(_val.get()), 24);
set(_val.get(), 24);
}
audio::int24_24_t::int24_24_t(const audio::int32_32_t& _val) {
int32_t val = _val.get() >> 8;
set(val, 24);
int64_t val = _val.get() >> 8;
set(val, 23);
}
audio::int24_24_t::int24_24_t(const audio::int32_64_t& _val) {
@ -50,17 +50,17 @@ audio::int24_24_t::int24_24_t(const audio::int32_64_t& _val) {
audio::int24_24_t::int24_24_t(const audio::int64_64_t& _val) {
int64_t val = _val.get() >> (32+8);
set(int32_t(val), 24);
set(int32_t(val), 23);
}
audio::int24_24_t::int24_24_t(const audio::float_t& _val) {
float val = _val.get() * float(INT24_MAX);
set(int32_t(val), 24);
float val = _val.get() * (float(INT24_MAX)+1);
set(int32_t(val), 23);
}
audio::int24_24_t::int24_24_t(const audio::double_t& _val) {
double val = _val.get() * double(INT24_MAX);
set(int32_t(val), 24);
double val = _val.get() * (double(INT24_MAX)+1);
set(int32_t(val), 23);
}
// set operator
@ -69,11 +69,17 @@ 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) {
int64_t val = _value << (23-_flotingPointPosition);
int64_t val;
if (_flotingPointPosition > 23) {
val = _value >> (-23+_flotingPointPosition);
} else {
val = _value << (23-_flotingPointPosition);
}
//AUDIO_INFO(" _value=" << _value << " _flotingPointPosition=" << _flotingPointPosition << " val=" << val);
val = std::avg(int64_t(INT24_MIN), val, int64_t(INT24_MAX));
m_data[0] = (val & 0x000000ff);
m_data[1] = (val & 0x0000ff00) >> 8;
m_data[2] = (val & 0x00ff0000) >> 16;
m_data[0] = (val & 0x00000000000000ffLL);
m_data[1] = (val & 0x000000000000ff00LL) >> 8;
m_data[2] = (val & 0x0000000000ff0000LL) >> 16;
}
void audio::int24_24_t::set(int32_t _value) {

View File

@ -100,7 +100,7 @@ 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) {
_os << "[" << etk::to_string(_obj.get()) << "7:24=";
_os << "[" << etk::to_string(_obj.get()) << ":7.24=";
_os << etk::to_string(double(_obj.get())/double(INT24_MAX)*0.5);
_os << "]";
return _os;

View File

@ -160,7 +160,7 @@ namespace audio {
}
int24_32_t operator++(int _unused) {
int24_32_t result(m_data);
result.m_data += (1<<24);
m_data += (1<<24);
return result;
}
/* ****************************************************
@ -172,7 +172,7 @@ namespace audio {
}
int24_32_t operator--(int _unused) {
int24_32_t result(m_data);
result.m_data -= (1<<24);
m_data -= (1<<24);
return result;
}
};

View File

@ -34,9 +34,9 @@ audio::int32_32_t::int32_32_t(const audio::int8_8_t& _val) {
}
audio::int32_32_t::int32_32_t(const audio::int8_16_t& _val) {
m_data = int32_t(std::avg(int16_t(INT8_MIN),
_val.get(),
int16_t(INT8_MAX)
m_data = int32_t(std::avg(int32_t(INT8_MIN),
_val.get() >> 1,
int32_t(INT8_MAX)
) << 24
);
}
@ -47,7 +47,7 @@ audio::int32_32_t::int32_32_t(const audio::int16_16_t& _val) {
audio::int32_32_t::int32_32_t(const audio::int16_32_t& _val) {
m_data = int32_t(std::avg(int32_t(INT16_MIN),
_val.get(),
_val.get() >> 1,
int32_t(INT16_MAX)
) << 16
);
@ -59,7 +59,7 @@ audio::int32_32_t::int32_32_t(const audio::int24_24_t& _val) {
audio::int32_32_t::int32_32_t(const audio::int24_32_t& _val) {
m_data = int32_t(std::avg(int32_t(INT24_MIN),
_val.get(),
_val.get() >> 1,
int32_t(INT24_MAX)
) << 8
);
@ -71,7 +71,7 @@ audio::int32_32_t::int32_32_t(const audio::int32_32_t& _val) {
audio::int32_32_t::int32_32_t(const audio::int32_64_t& _val) {
m_data = int32_t(std::avg(int64_t(INT32_MIN),
_val.get(),
_val.get() >> 1,
int64_t(INT32_MAX)
)
);

View File

@ -123,7 +123,7 @@ namespace audio {
* *= operator
*****************************************************/
const int32_32_t& operator*= (const int32_32_t& _obj) {
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1LL<<30);
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
m_data = int32_t(tmp >> 31);
return *this;
}

View File

@ -69,15 +69,15 @@ audio::int32_64_t::int32_64_t(const audio::float_t& _val) {
m_data = int64_t(std::avg(float(INT32_MIN),
_val.get(),
float(INT32_MAX)
) * float(INT32_MAX) * 2.0f
) * (float(INT32_MAX) * 2.0f + 1.0f)
);
}
audio::int32_64_t::int32_64_t(const audio::double_t& _val) {
m_data = int64_t(std::avg(double(INT32_MIN),
_val.get(),
double(INT32_MIN)
) * double(INT32_MAX) * 2.0
double(INT32_MAX)
) * (double(INT32_MAX) * 2.0 + 1.0)
);
}

View File

@ -132,7 +132,7 @@ namespace audio {
* /= operator
*****************************************************/
const int32_64_t& operator/= (const int32_64_t& _obj) {
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data) + (1LL<<15);
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
m_data = int64_t(tmp)<<16;
return *this;
}
@ -153,7 +153,7 @@ namespace audio {
}
int32_64_t operator++(int _unused) {
int32_64_t result(m_data);
result.m_data += (1LL<<32);
m_data += (1LL<<32);
return result;
}
/* ****************************************************
@ -165,7 +165,7 @@ namespace audio {
}
int32_64_t operator--(int _unused) {
int32_64_t result(m_data);
result.m_data -= (1LL<<32);
m_data -= (1LL<<32);
return result;
}
};

View File

@ -81,7 +81,7 @@ audio::int64_64_t::int64_64_t(const audio::float_t& _val) {
m_data = int64_t(std::avg(-1.0f,
_val.get(),
1.0f
) * double(INT64_MAX)
) * (float(INT64_MAX) + 1.0f)
);
}
@ -89,7 +89,7 @@ audio::int64_64_t::int64_64_t(const audio::double_t& _val) {
m_data = int64_t(std::avg(-1.0,
_val.get(),
1.0
) * double(INT64_MAX)
) * (double(INT64_MAX) + 1.0f)
);
}
@ -98,6 +98,7 @@ 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) {
// TODO: do it better with int128_t elements
int64_t val = _value << (63-_flotingPointPosition);
m_data = std::avg(int64_t(INT64_MIN), val, int64_t(INT64_MAX));
}

View File

@ -118,8 +118,26 @@ namespace audio {
* *= operator
*****************************************************/
const int64_64_t& operator*= (const int64_64_t& _obj) {
int16_t tmp = (m_data >> 31) * (_obj.m_data >> 32);
m_data = tmp;
if ( m_data > INT32_MAX
|| m_data < INT32_MIN) {
if ( _obj.m_data > INT32_MAX
|| _obj.m_data < INT32_MIN) {
int64_t tmp = (m_data >> 31) * (_obj.m_data >> 31);
m_data = tmp >> 1;
} else {
int64_t tmp = (m_data >> 31) * (_obj.m_data);
m_data = tmp >> 32;
}
} else {
if ( _obj.m_data > INT32_MAX
|| _obj.m_data < INT32_MIN) {
int64_t tmp = (m_data) * (_obj.m_data >> 32);
m_data = tmp >> 31;
} else {
int64_t tmp = (m_data >> 24) * (_obj.m_data >> 24);
m_data = tmp >> 16;
}
}
return *this;
}
/* ****************************************************
@ -134,8 +152,9 @@ namespace audio {
* /= operator
*****************************************************/
const int64_64_t& operator/= (const int64_64_t& _obj) {
int64_t tmp = (m_data << 31) / (_obj.m_data>>32);
m_data = tmp;
// TODO: Does not work
int64_t tmp = (m_data) / (_obj.m_data);
m_data = tmp << 63;
return *this;
}
/* ****************************************************

View File

@ -139,8 +139,8 @@ namespace audio {
* /= operator
*****************************************************/
const int8_16_t& operator/= (const int8_16_t& _obj) {
int16_t tmp = (int16_t(m_data) << 8) / int16_t(_obj.m_data);
m_data = int8_t(tmp);
int32_t tmp = (int32_t(m_data) << 8) / int32_t(_obj.m_data);
m_data = int16_t(tmp);
return *this;
}
/* ****************************************************
@ -160,7 +160,7 @@ namespace audio {
}
int8_16_t operator++(int _unused) {
int8_16_t result(m_data);
result.m_data += (1<<8);
m_data += (1<<8);
return result;
}
/* ****************************************************
@ -172,7 +172,7 @@ namespace audio {
}
int8_16_t operator--(int _unused) {
int8_16_t result(m_data);
result.m_data -= (1<<8);
m_data -= (1<<8);
return result;
}
};

View File

@ -123,7 +123,7 @@ namespace audio {
* *= operator
*****************************************************/
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) + (1LL<<5);
m_data = int8_t(tmp >> 7);
return *this;
}

View File

@ -11,16 +11,19 @@ def create(target):
myModule = module.Module(__file__, 'audio_test', 'BINARY')
myModule.add_src_file([
'test/debug.cpp',
'test/main.cpp',
'test/base.cpp',
'test/test_int8_8.cpp',
'test/test_int8_16.cpp',
'test/main.cpp',
'test/test_double.cpp',
'test/test_float.cpp',
'test/test_int16_16.cpp',
'test/test_int16_32.cpp',
'test/test_int24_24.cpp',
'test/test_int24_32.cpp',
'test/test_int32_32.cpp',
'test/test_int32_64.cpp',
'test/test_int64_64.cpp',
'test/test_float.cpp'
'test/test_int8_16.cpp',
'test/test_int8_8.cpp'
])
myModule.add_module_depend(['audio', 'gtest'])
return myModule

View File

@ -141,24 +141,24 @@ TEST(TestBase, type_int64_64_t) {
}
TEST(TestBase, type_float_t) {
audio::float_t typeBase(16, 1);
audio::float_t typeBase(16, 0);
EXPECT_EQ(typeBase.get(), 16.0);
typeBase.set(INT32_MIN, 1);
typeBase.set(INT32_MIN, 0);
EXPECT_EQ(typeBase.get(), INT32_MIN);
typeBase.set(INT32_MAX, 1);
typeBase.set(INT32_MAX, 0);
EXPECT_EQ(typeBase.get(), INT32_MAX);
typeBase.set(int64_t(INT32_MAX)+200, 1);
typeBase.set(int64_t(INT32_MAX)+200, 0);
EXPECT_EQ(typeBase.get(), 2.147483840e+09f); // Note : floating point error
typeBase.set(int64_t(INT32_MIN)-200, 1);
typeBase.set(int64_t(INT32_MIN)-200, 0);
EXPECT_EQ(typeBase.get(), -2.147483904e+09f); // Note : floating point error
typeBase.set(-250.0f);
EXPECT_EQ(typeBase.get(), -250.0f);
}
TEST(TestBase, type_double_t) {
audio::double_t typeBase(16, 1);
audio::double_t typeBase(16, 0);
EXPECT_EQ(int64_t(typeBase.get()), 16LL);
EXPECT_EQ(typeBase.get(), 16.00000000745058); // Note : double point error
EXPECT_EQ(typeBase.get(), 16.0); // Note : double point error
typeBase.set(-250.0);
EXPECT_EQ(typeBase.get(), -250.0);
}

View File

@ -0,0 +1,185 @@
/** @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(TesDouble, basicConstructorBase) {
audio::double_t typeBase(25.0);
EXPECT_EQ(typeBase.get(), 25.0);
}
TEST(TesDouble, basicConstructorSetOne) {
audio::double_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), 1.0);
}
TEST(TesDouble, basicConstructorSetLessOne) {
audio::double_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), -1.0);
}
TEST(TesDouble, basicOperatorEqual) {
audio::double_t typeBase;
typeBase = 35.0;
EXPECT_EQ(typeBase.get(), 35.0);
}
TEST(TesDouble, basicOperatorPlus) {
audio::double_t typeBase(35.0);
typeBase += 35.0;
EXPECT_EQ(typeBase.get(), 70.0);
}
TEST(TesDouble, basicOperatorMinus) {
audio::double_t typeBase(55.0);
typeBase -= 35.0;
EXPECT_EQ(typeBase.get(), 20.0);
typeBase -= 35.0;
EXPECT_EQ(typeBase.get(), -15.0);
}
TEST(TesDouble, basicOperatorMultiplication) {
audio::double_t typeBase(-1, 0);
typeBase *= 35.0;
EXPECT_EQ(typeBase.get(), -35.0);
typeBase = 0.6;
typeBase *= 0.3;
EXPECT_EQ(typeBase.get(), 0.18);
}
TEST(TestDouble, basicOperatorCompareEquality) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestDouble, basicOperatorCompareInEquality) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestDouble, basicOperatorCompareMinor) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestDouble, basicOperatorCompareEqualityMinor) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestDouble, basicOperatorCompareMajor) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestDouble, basicOperatorCompareEqualityMajor) {
audio::double_t typeBase1(-12, 5);
audio::double_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestDouble, basicOperatorLiteralPlus) {
audio::double_t out;
out = audio::double_t(-13, 5) + audio::double_t(12, 5);
EXPECT_EQ(out.get(), audio::double_t(-1,5).get());
}
TEST(TestDouble, basicOperatorLiteralMinus) {
audio::double_t out;
out = audio::double_t(-13, 5) - audio::double_t(12, 5);
EXPECT_EQ(out.get(), audio::double_t(-25,5).get());
}
TEST(TestDouble, basicOperatorLiteralMultiplication) {
audio::double_t out;
out = audio::double_t(-5, 3) * audio::double_t(3, 3);
EXPECT_EQ(out.get(), audio::double_t(-15,6).get());
}
TEST(TestDouble, basicOperatorDividing) {
audio::double_t out(-15, 2);
out /= audio::double_t(3, 2);
EXPECT_EQ(out.get(), audio::double_t(-5,0).get());
}
TEST(TestDouble, basicOperatorLiteralDividing) {
audio::double_t out;
out = audio::double_t(-15, 2) / audio::double_t(3, 2);
EXPECT_EQ(out.get(), audio::double_t(-5,0).get());
}
TEST(TestDouble, basicOperatorIncrementPost) {
audio::double_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::double_t(11, 0).get());
}
TEST(TestDouble, basicOperatorIncrementPre) {
audio::double_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::double_t(11, 0).get());
}
TEST(TestDouble, basicOperatorDecrementPost) {
audio::double_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::double_t(9, 0).get());
}
TEST(TestDouble, basicOperatorDecrementPre) {
audio::double_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::double_t(9, 0).get());
}

View File

@ -0,0 +1,230 @@
/** @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(TestFloat, basicConstructorBase) {
audio::float_t typeBase(25.0f);
EXPECT_EQ(typeBase.get(), 25.0f);
}
TEST(TestFloat, basicConstructorSetOne) {
audio::float_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), 1.0f);
}
TEST(TestFloat, basicConstructorSetLessOne) {
audio::float_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), -1.0f);
}
TEST(TestFloat, basicOperatorEqual) {
audio::float_t typeBase;
typeBase = 35.0f;
EXPECT_EQ(typeBase.get(), 35.0f);
}
TEST(TestFloat, basicOperatorPlus) {
audio::float_t typeBase(35.0f);
typeBase += 35.0f;
EXPECT_EQ(typeBase.get(), 70.0f);
}
TEST(TestFloat, basicOperatorMinus) {
audio::float_t typeBase(55.0f);
typeBase -= 35.0f;
EXPECT_EQ(typeBase.get(), 20.0f);
typeBase -= 35.0f;
EXPECT_EQ(typeBase.get(), -15.0f);
}
TEST(TestFloat, basicOperatorMultiplication) {
audio::float_t typeBase(-1, 0);
typeBase *= 35.0f;
EXPECT_EQ(typeBase.get(), -35.0f);
typeBase = 0.6f;
typeBase *= 0.3f;
EXPECT_EQ(typeBase.get(), 0.18f);
}
TEST(TestFloat, basicOperatorCompareEquality) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestFloat, basicOperatorCompareInEquality) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestFloat, basicOperatorCompareMinor) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestFloat, basicOperatorCompareEqualityMinor) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestFloat, basicOperatorCompareMajor) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestFloat, basicOperatorCompareEqualityMajor) {
audio::float_t typeBase1(-12, 5);
audio::float_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestFloat, basicOperatorLiteralPlus) {
audio::float_t out;
out = audio::float_t(-13, 5) + audio::float_t(12, 5);
EXPECT_EQ(out.get(), audio::float_t(-1,5).get());
}
TEST(TestFloat, basicOperatorLiteralMinus) {
audio::float_t out;
out = audio::float_t(-13, 5) - audio::float_t(12, 5);
EXPECT_EQ(out.get(), audio::float_t(-25,5).get());
}
TEST(TestFloat, basicOperatorLiteralMultiplication) {
audio::float_t out;
out = audio::float_t(-5, 3) * audio::float_t(3, 3);
EXPECT_EQ(out.get(), audio::float_t(-15,6).get());
}
TEST(TestFloat, basicOperatorDividing) {
audio::float_t out(-15, 2);
out /= audio::float_t(3, 2);
EXPECT_EQ(out.get(), audio::float_t(-5,0).get());
}
TEST(TestFloat, basicOperatorLiteralDividing) {
audio::float_t out;
out = audio::float_t(-15, 2) / audio::float_t(3, 2);
EXPECT_EQ(out.get(), audio::float_t(-5,0).get());
}
TEST(TestFloat, basicOperatorIncrementPost) {
audio::float_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::float_t(11, 0).get());
}
TEST(TestFloat, basicOperatorIncrementPre) {
audio::float_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::float_t(11, 0).get());
}
TEST(TestFloat, basicOperatorDecrementPost) {
audio::float_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::float_t(9, 0).get());
}
TEST(TestFloat, basicOperatorDecrementPre) {
audio::float_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::float_t(9, 0).get());
}
#define RESULT_VALUE (0.3125)
TEST(TestFloat, basicConstructorInt8_8) {
audio::float_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt8_16) {
audio::float_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt16_16) {
audio::float_t out(audio::int16_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt24_24) {
audio::float_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt24_32) {
audio::float_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt16_32) {
audio::float_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt32_32) {
audio::float_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt32_64) {
audio::float_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorInt64_64) {
audio::float_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorFloat) {
audio::float_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestFloat, basicConstructorDouble) {
audio::float_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -10,20 +10,225 @@
TEST(TestInt16_16, basicOperator) {
TEST(TestInt16_16, basicConstructorBase) {
audio::int16_16_t typeBase(16);
audio::int16_16_t out(1, 0);
EXPECT_EQ(out.get(), ((1<<15)-1));
out *= 16;
EXPECT_EQ(out.get(), 16);
out = 1;
EXPECT_EQ(out.get(), 1);
out *= typeBase;
EXPECT_EQ(out.get(), 0);
out = audio::float_t(0.3);
out += audio::float_t(0.3);
EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3);
EXPECT_EQ(out.get(), audio::int16_16_t(audio::float_t(0.18)).get());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt16_16, basicConstructorSetOne) {
audio::int16_16_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1<<15)-1));
}
TEST(TestInt16_16, basicConstructorSetLessOne) {
audio::int16_16_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1<<15)));
}
TEST(TestInt16_16, basicOperatorEqual) {
audio::int16_16_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt16_16, basicOperatorPlus) {
audio::int16_16_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt16_16, basicOperatorMinus) {
audio::int16_16_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt16_16, basicOperatorMultiplication) {
audio::int16_16_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), audio::int16_16_t(audio::double_t(0.1799856)).get());
}
TEST(TestInt16_16, basicOperatorCompareEquality) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_16, basicOperatorCompareInEquality) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_16, basicOperatorCompareMinor) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_16, basicOperatorCompareEqualityMinor) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_16, basicOperatorCompareMajor) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_16, basicOperatorCompareEqualityMajor) {
audio::int16_16_t typeBase1(-12, 5);
audio::int16_16_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_16, basicOperatorLiteralPlus) {
audio::int16_16_t out;
out = audio::int16_16_t(-13, 5) + audio::int16_16_t(12, 5);
EXPECT_EQ(out.get(), audio::int16_16_t(-1,5).get());
}
TEST(TestInt16_16, basicOperatorLiteralMinus) {
audio::int16_16_t out;
out = audio::int16_16_t(-13, 5) - audio::int16_16_t(12, 5);
EXPECT_EQ(out.get(), audio::int16_16_t(-25,5).get());
}
TEST(TestInt16_16, basicOperatorLiteralMultiplication) {
audio::int16_16_t out;
out = audio::int16_16_t(-5, 3) * audio::int16_16_t(3, 3);
EXPECT_EQ(out.get(), audio::int16_16_t(-15,6).get());
}
TEST(TestInt16_16, basicOperatorDividing) {
audio::int16_16_t out(-15, 5);
out /= audio::int16_16_t(3, 2);
EXPECT_EQ(out.get(), audio::int16_16_t(-5,3).get());
}
TEST(TestInt16_16, basicOperatorLiteralDividing) {
audio::int16_16_t out;
out = audio::int16_16_t(-15, 5) / audio::int16_16_t(3, 2);
EXPECT_EQ(out.get(), audio::int16_16_t(-5,3).get());
}
/*
TEST(TestInt16_16, basicOperatorIncrementPost) {
audio::int16_16_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int16_16_t(11, 0).get());
}
TEST(TestInt16_16, basicOperatorIncrementPre) {
audio::int16_16_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int16_16_t(11, 0).get());
}
TEST(TestInt16_16, basicOperatorDecrementPost) {
audio::int16_16_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int16_16_t(9, 0).get());
}
TEST(TestInt16_16, basicOperatorDecrementPre) {
audio::int16_16_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int16_16_t(9, 0).get());
}
*/
#define RESULT_VALUE (10240)
TEST(TestInt16_16, basicConstructorInt8_8) {
audio::int16_16_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt8_16) {
audio::int16_16_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt16_16) {
audio::int16_16_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int16_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt24_24) {
audio::int16_16_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt24_32) {
audio::int16_16_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt16_32) {
audio::int16_16_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt32_32) {
audio::int16_16_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt32_64) {
audio::int16_16_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorInt64_64) {
audio::int16_16_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorFloat) {
audio::int16_16_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_16, basicConstructorDouble) {
audio::int16_16_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -9,30 +9,225 @@
#include <audio/types.h>
TEST(TestInt16_32, basicOperator) {
TEST(TestInt16_32, basicConstructorBase) {
audio::int16_32_t typeBase(16);
audio::int16_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::int16_32_t(audio::float_t(0.6)).get());
out *= audio::float_t(0.3);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), audio::int16_32_t(audio::float_t(0.18)).get());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt16_32, basicConstructorSetOne) {
audio::int16_32_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1<<16)));
}
TEST(TestInt16_32, basicConstructorSetLessOne) {
audio::int16_32_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1<<16)));
}
TEST(TestInt16_32, basicOperatorEqual) {
audio::int16_32_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt16_32, basicOperatorPlus) {
audio::int16_32_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt16_32, basicOperatorMinus) {
audio::int16_32_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt16_32, basicOperatorMultiplication) {
audio::int16_32_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), audio::int16_32_t(audio::double_t(0.18)).get());
}
TEST(TestInt16_32, basicOperatorCompareEquality) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_32, basicOperatorCompareInEquality) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_32, basicOperatorCompareMinor) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_32, basicOperatorCompareEqualityMinor) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt16_32, basicOperatorCompareMajor) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_32, basicOperatorCompareEqualityMajor) {
audio::int16_32_t typeBase1(-12, 5);
audio::int16_32_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt16_32, basicOperatorLiteralPlus) {
audio::int16_32_t out;
out = audio::int16_32_t(-13, 5) + audio::int16_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int16_32_t(-1,5).get());
}
TEST(TestInt16_32, basicOperatorLiteralMinus) {
audio::int16_32_t out;
out = audio::int16_32_t(-13, 5) - audio::int16_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int16_32_t(-25,5).get());
}
TEST(TestInt16_32, basicOperatorLiteralMultiplication) {
audio::int16_32_t out;
out = audio::int16_32_t(-5, 3) * audio::int16_32_t(3, 3);
EXPECT_EQ(out.get(), audio::int16_32_t(-15,6).get());
}
TEST(TestInt16_32, basicOperatorDividing) {
audio::int16_32_t out(-15, 2);
out /= audio::int16_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int16_32_t(-5,0).get());
}
TEST(TestInt16_32, basicOperatorLiteralDividing) {
audio::int16_32_t out;
out = audio::int16_32_t(-15, 2) / audio::int16_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int16_32_t(-5,0).get());
}
TEST(TestInt16_32, basicOperatorIncrementPost) {
audio::int16_32_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int16_32_t(11, 0).get());
}
TEST(TestInt16_32, basicOperatorIncrementPre) {
audio::int16_32_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int16_32_t(11, 0).get());
}
TEST(TestInt16_32, basicOperatorDecrementPost) {
audio::int16_32_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int16_32_t(9, 0).get());
}
TEST(TestInt16_32, basicOperatorDecrementPre) {
audio::int16_32_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int16_32_t(9, 0).get());
}
#define RESULT_VALUE (20480)
TEST(TestInt16_32, basicConstructorInt8_8) {
audio::int16_32_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt8_16) {
audio::int16_32_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt16_16) {
audio::int16_32_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt24_24) {
audio::int16_32_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt24_32) {
audio::int16_32_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt16_32) {
audio::int16_32_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt32_32) {
audio::int16_32_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt32_64) {
audio::int16_32_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorInt64_64) {
audio::int16_32_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt16_32, basicConstructorFloat) {
audio::int16_32_t out(audio::float_t(5,4));
EXPECT_EQ(20479, out.get());
}
TEST(TestInt16_32, basicConstructorDouble) {
audio::int16_32_t out(audio::double_t(5,4));
EXPECT_EQ(20479, out.get());
}

105
test/test_int24_24.cpp Normal file
View File

@ -0,0 +1,105 @@
/**
* @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_24, basicConstructorBase) {
audio::int24_24_t typeBase(16);
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt24_24, basicConstructorSetOne) {
audio::int24_24_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1<<23)-1));
}
TEST(TestInt24_24, basicConstructorSetLessOne) {
audio::int24_24_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1<<23)));
}
/*
TEST(TestInt24_24, basicOperatorEqual) {
audio::int24_24_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt24_24, basicOperatorPlus) {
audio::int24_24_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt24_24, basicOperatorMinus) {
audio::int24_24_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt24_24, basicOperatorMultiplication) {
audio::int24_24_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::float_t(0.6);
typeBase *= audio::float_t(0.3);
EXPECT_EQ(typeBase.get(), audio::int24_24_t(audio::float_t(0.18)).get());
}
*/
#define RESULT_VALUE (2621440)
TEST(TestInt24_24, basicConstructorInt8_8) {
audio::int24_24_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt8_16) {
audio::int24_24_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt16_16) {
audio::int24_24_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt24_24) {
audio::int24_24_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt24_32) {
audio::int24_24_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt16_32) {
audio::int24_24_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt32_32) {
audio::int24_24_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt32_64) {
audio::int24_24_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorInt64_64) {
audio::int24_24_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorFloat) {
audio::int24_24_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_24, basicConstructorDouble) {
audio::int24_24_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -9,30 +9,225 @@
#include <audio/types.h>
TEST(TestInt24_32, basicOperator) {
TEST(TestInt24_32, basicConstructorBase) {
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());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt24_32, basicConstructorSetOne) {
audio::int24_32_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1<<24)));
}
TEST(TestInt24_32, basicConstructorSetLessOne) {
audio::int24_32_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1<<24)));
}
TEST(TestInt24_32, basicOperatorEqual) {
audio::int24_32_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt24_32, basicOperatorPlus) {
audio::int24_32_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt24_32, basicOperatorMinus) {
audio::int24_32_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt24_32, basicOperatorMultiplication) {
audio::int24_32_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::int24_32_t(3,5);
typeBase *= audio::int24_32_t(3,1);
EXPECT_EQ(typeBase.get(), audio::int24_32_t(9,6).get());
}
TEST(TestInt24_32, basicOperatorCompareEquality) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt24_32, basicOperatorCompareInEquality) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt24_32, basicOperatorCompareMinor) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt24_32, basicOperatorCompareEqualityMinor) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt24_32, basicOperatorCompareMajor) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt24_32, basicOperatorCompareEqualityMajor) {
audio::int24_32_t typeBase1(-12, 5);
audio::int24_32_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt24_32, basicOperatorLiteralPlus) {
audio::int24_32_t out;
out = audio::int24_32_t(-13, 5) + audio::int24_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int24_32_t(-1,5).get());
}
TEST(TestInt24_32, basicOperatorLiteralMinus) {
audio::int24_32_t out;
out = audio::int24_32_t(-13, 5) - audio::int24_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int24_32_t(-25,5).get());
}
TEST(TestInt24_32, basicOperatorLiteralMultiplication) {
audio::int24_32_t out;
out = audio::int24_32_t(-5, 3) * audio::int24_32_t(3, 3);
EXPECT_EQ(out.get(), audio::int24_32_t(-15,6).get());
}
TEST(TestInt24_32, basicOperatorDividing) {
audio::int24_32_t out(-15, 2);
out /= audio::int24_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int24_32_t(-5,0).get());
}
TEST(TestInt24_32, basicOperatorLiteralDividing) {
audio::int24_32_t out;
out = audio::int24_32_t(-15, 2) / audio::int24_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int24_32_t(-5,0).get());
}
TEST(TestInt24_32, basicOperatorIncrementPost) {
audio::int24_32_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int24_32_t(11, 0).get());
}
TEST(TestInt24_32, basicOperatorIncrementPre) {
audio::int24_32_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int24_32_t(11, 0).get());
}
TEST(TestInt24_32, basicOperatorDecrementPost) {
audio::int24_32_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int24_32_t(9, 0).get());
}
TEST(TestInt24_32, basicOperatorDecrementPre) {
audio::int24_32_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int24_32_t(9, 0).get());
}
#define RESULT_VALUE (5242880)
TEST(TestInt24_32, basicConstructorInt8_8) {
audio::int24_32_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt8_16) {
audio::int24_32_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt16_16) {
audio::int24_32_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt24_24) {
audio::int24_32_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt24_32) {
audio::int24_32_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt16_32) {
audio::int24_32_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt32_32) {
audio::int24_32_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt32_64) {
audio::int24_32_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorInt64_64) {
audio::int24_32_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorFloat) {
audio::int24_32_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt24_32, basicConstructorDouble) {
audio::int24_32_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -9,30 +9,226 @@
#include <audio/types.h>
TEST(TestInt32_32, basicOperator) {
TEST(TestInt32_32, basicConstructorBase) {
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());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt32_32, basicConstructorSetOne) {
audio::int32_32_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1LL<<31)-1));
}
TEST(TestInt32_32, basicConstructorSetLessOne) {
audio::int32_32_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1LL<<31)));
}
TEST(TestInt32_32, basicOperatorEqual) {
audio::int32_32_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt32_32, basicOperatorPlus) {
audio::int32_32_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt32_32, basicOperatorMinus) {
audio::int32_32_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt32_32, basicOperatorMultiplication) {
audio::int32_32_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), audio::int32_32_t(audio::double_t(0.18)).get());
}
TEST(TestInt32_32, basicOperatorCompareEquality) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_32, basicOperatorCompareInEquality) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_32, basicOperatorCompareMinor) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_32, basicOperatorCompareEqualityMinor) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_32, basicOperatorCompareMajor) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_32, basicOperatorCompareEqualityMajor) {
audio::int32_32_t typeBase1(-12, 5);
audio::int32_32_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_32, basicOperatorLiteralPlus) {
audio::int32_32_t out;
out = audio::int32_32_t(-13, 5) + audio::int32_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int32_32_t(-1,5).get());
}
TEST(TestInt32_32, basicOperatorLiteralMinus) {
audio::int32_32_t out;
out = audio::int32_32_t(-13, 5) - audio::int32_32_t(12, 5);
EXPECT_EQ(out.get(), audio::int32_32_t(-25,5).get());
}
TEST(TestInt32_32, basicOperatorLiteralMultiplication) {
audio::int32_32_t out;
out = audio::int32_32_t(-5, 3) * audio::int32_32_t(3, 3);
EXPECT_EQ(out.get(), audio::int32_32_t(-15,6).get());
}
TEST(TestInt32_32, basicOperatorDividing) {
audio::int32_32_t out(-15, 5);
out /= audio::int32_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int32_32_t(-5,3).get());
}
TEST(TestInt32_32, basicOperatorLiteralDividing) {
audio::int32_32_t out;
out = audio::int32_32_t(-15, 5) / audio::int32_32_t(3, 2);
EXPECT_EQ(out.get(), audio::int32_32_t(-5,3).get());
}
/*
TEST(TestInt32_32, basicOperatorIncrementPost) {
audio::int32_32_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int32_32_t(11, 0).get());
}
TEST(TestInt32_32, basicOperatorIncrementPre) {
audio::int32_32_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int32_32_t(11, 0).get());
}
TEST(TestInt32_32, basicOperatorDecrementPost) {
audio::int32_32_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int32_32_t(9, 0).get());
}
TEST(TestInt32_32, basicOperatorDecrementPre) {
audio::int32_32_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int32_32_t(9, 0).get());
}
*/
#define RESULT_VALUE (671088640)
TEST(TestInt32_32, basicConstructorInt8_8) {
audio::int32_32_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt8_16) {
audio::int32_32_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt16_16) {
audio::int32_32_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt24_24) {
audio::int32_32_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt24_32) {
audio::int32_32_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt16_32) {
audio::int32_32_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt32_32) {
audio::int32_32_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt32_64) {
audio::int32_32_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorInt64_64) {
audio::int32_32_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorFloat) {
audio::int32_32_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_32, basicConstructorDouble) {
audio::int32_32_t out(audio::double_t(5,4));
EXPECT_EQ(671088639, out.get());
}

View File

@ -9,30 +9,225 @@
#include <audio/types.h>
TEST(TestInt32_64, basicOperator) {
TEST(TestInt32_64, basicConstructorBase) {
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());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt32_64, basicConstructorSetOne) {
audio::int32_64_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1LL<<32)));
}
TEST(TestInt32_64, basicConstructorSetLessOne) {
audio::int32_64_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1LL<<32)));
}
TEST(TestInt32_64, basicOperatorEqual) {
audio::int32_64_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt32_64, basicOperatorPlus) {
audio::int32_64_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt32_64, basicOperatorMinus) {
audio::int32_64_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt32_64, basicOperatorMultiplication) {
audio::int32_64_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), 773094112LL);
}
TEST(TestInt32_64, basicOperatorCompareEquality) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_64, basicOperatorCompareInEquality) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_64, basicOperatorCompareMinor) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_64, basicOperatorCompareEqualityMinor) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt32_64, basicOperatorCompareMajor) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_64, basicOperatorCompareEqualityMajor) {
audio::int32_64_t typeBase1(-12, 5);
audio::int32_64_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt32_64, basicOperatorLiteralPlus) {
audio::int32_64_t out;
out = audio::int32_64_t(-13, 5) + audio::int32_64_t(12, 5);
EXPECT_EQ(out.get(), audio::int32_64_t(-1,5).get());
}
TEST(TestInt32_64, basicOperatorLiteralMinus) {
audio::int32_64_t out;
out = audio::int32_64_t(-13, 5) - audio::int32_64_t(12, 5);
EXPECT_EQ(out.get(), audio::int32_64_t(-25,5).get());
}
TEST(TestInt32_64, basicOperatorLiteralMultiplication) {
audio::int32_64_t out;
out = audio::int32_64_t(-5, 3) * audio::int32_64_t(3, 3);
EXPECT_EQ(out.get(), audio::int32_64_t(-15,6).get());
}
TEST(TestInt32_64, basicOperatorDividing) {
audio::int32_64_t out(-15, 2);
out /= audio::int32_64_t(3, 2);
EXPECT_EQ(out.get(), audio::int32_64_t(-5,0).get());
}
TEST(TestInt32_64, basicOperatorLiteralDividing) {
audio::int32_64_t out;
out = audio::int32_64_t(-15, 2) / audio::int32_64_t(3, 2);
EXPECT_EQ(out.get(), audio::int32_64_t(-5,0).get());
}
TEST(TestInt32_64, basicOperatorIncrementPost) {
audio::int32_64_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int32_64_t(11, 0).get());
}
TEST(TestInt32_64, basicOperatorIncrementPre) {
audio::int32_64_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int32_64_t(11, 0).get());
}
TEST(TestInt32_64, basicOperatorDecrementPost) {
audio::int32_64_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int32_64_t(9, 0).get());
}
TEST(TestInt32_64, basicOperatorDecrementPre) {
audio::int32_64_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int32_64_t(9, 0).get());
}
#define RESULT_VALUE (1342177280LL)
TEST(TestInt32_64, basicConstructorInt8_8) {
audio::int32_64_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt8_16) {
audio::int32_64_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt16_16) {
audio::int32_64_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt24_24) {
audio::int32_64_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt24_32) {
audio::int32_64_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt16_32) {
audio::int32_64_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt32_32) {
audio::int32_64_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt32_64) {
audio::int32_64_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorInt64_64) {
audio::int32_64_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorFloat) {
audio::int32_64_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt32_64, basicConstructorDouble) {
audio::int32_64_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -9,30 +9,250 @@
#include <audio/types.h>
/*
TEST(TestInt64_64, basicOperator) {
audio::int64_64_t typeBase(16);
audio::int64_64_t out(1, 0);
audio::int64_64_t out(0x7FFFFFFFFFFFFFFFLL, 63);
APPL_INFO(" data = " << out);
EXPECT_EQ(out.get(), INT64_MAX);
EXPECT_EQ(out.get(), 0x7FFFFFFFFFFFFFFFLL);
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());
EXPECT_EQ(out.get(), 1660206965216520438LL);
}
*/
TEST(TestInt64_64, basicConstructorBase) {
audio::int64_64_t typeBase(16);
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt64_64, basicConstructorSetOne) {
// only one way to set the maximum value
audio::int64_64_t typeBase(0x7FFFFFFFFFFFFFFFLL, 63);
EXPECT_EQ(typeBase.get(), 0x7FFFFFFFFFFFFFFFLL);
}
TEST(TestInt64_64, basicConstructorSetLessOne) {
audio::int64_64_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1LL<<63)));
}
TEST(TestInt64_64, basicOperatorEqual) {
audio::int64_64_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt64_64, basicOperatorPlus) {
audio::int64_64_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt64_64, basicOperatorMinus) {
audio::int64_64_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt64_64, basicOperatorMultiplication) {
audio::int64_64_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), 1660206965216520438LL);
}
TEST(TestInt64_64, basicOperatorCompareEquality) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt64_64, basicOperatorCompareInEquality) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt64_64, basicOperatorCompareMinor) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt64_64, basicOperatorCompareEqualityMinor) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt64_64, basicOperatorCompareMajor) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt64_64, basicOperatorCompareEqualityMajor) {
audio::int64_64_t typeBase1(-12, 5);
audio::int64_64_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt64_64, basicOperatorLiteralPlus) {
audio::int64_64_t out;
out = audio::int64_64_t(-13, 5) + audio::int64_64_t(12, 5);
EXPECT_EQ(out.get(), audio::int64_64_t(-1,5).get());
}
TEST(TestInt64_64, basicOperatorLiteralMinus) {
audio::int64_64_t out;
out = audio::int64_64_t(-13, 5) - audio::int64_64_t(12, 5);
EXPECT_EQ(out.get(), audio::int64_64_t(-25,5).get());
}
TEST(TestInt64_64, basicOperatorLiteralMultiplication) {
audio::int64_64_t out;
out = audio::int64_64_t(-5, 3) * audio::int64_64_t(3, 3);
EXPECT_EQ(out.get(), audio::int64_64_t(-15,6).get());
}
/*
TEST(TestInt64_64, basicOperatorDividing) {
audio::int64_64_t out(-15, 5);
out /= audio::int64_64_t(3, 2);
EXPECT_EQ(out.get(), audio::int64_64_t(-5,3).get());
}
TEST(TestInt64_64, basicOperatorLiteralDividing) {
audio::int64_64_t out;
out = audio::int64_64_t(-15, 5) / audio::int64_64_t(3, 2);
EXPECT_EQ(out.get(), audio::int64_64_t(-5,3).get());
}
*/
/*
TEST(TestInt64_64, basicOperatorIncrementPost) {
audio::int64_64_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int64_64_t(11, 0).get());
}
TEST(TestInt64_64, basicOperatorIncrementPre) {
audio::int64_64_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int64_64_t(11, 0).get());
}
TEST(TestInt64_64, basicOperatorDecrementPost) {
audio::int64_64_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int64_64_t(9, 0).get());
}
TEST(TestInt64_64, basicOperatorDecrementPre) {
audio::int64_64_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int64_64_t(9, 0).get());
}
*/
#define RESULT_VALUE (2882303761517117440LL)
TEST(TestInt64_64, basicConstructorInt8_8) {
audio::int64_64_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt8_16) {
audio::int64_64_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt16_16) {
audio::int64_64_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt24_24) {
audio::int64_64_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt24_32) {
audio::int64_64_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt16_32) {
audio::int64_64_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt32_32) {
audio::int64_64_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt32_64) {
audio::int64_64_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorInt64_64) {
audio::int64_64_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorFloat) {
audio::int64_64_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt64_64, basicConstructorDouble) {
audio::int64_64_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -8,31 +8,226 @@
#include <gtest/gtest.h>
#include <audio/types.h>
TEST(TestInt8_16, basicOperator) {
TEST(TestInt8_16, basicConstructorBase) {
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());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt8_16, basicConstructorSetOne) {
audio::int8_16_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1LL<<8)));
}
TEST(TestInt8_16, basicConstructorSetLessOne) {
audio::int8_16_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1LL<<8)));
}
TEST(TestInt8_16, basicOperatorEqual) {
audio::int8_16_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt8_16, basicOperatorPlus) {
audio::int8_16_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt8_16, basicOperatorMinus) {
audio::int8_16_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt8_16, basicOperatorMultiplication) {
audio::int8_16_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::double_t(0.6);
typeBase *= audio::double_t(0.3);
EXPECT_EQ(typeBase.get(), audio::int8_16_t(audio::double_t(0.18)).get());
}
TEST(TestInt8_16, basicOperatorCompareEquality) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_16, basicOperatorCompareInEquality) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_16, basicOperatorCompareMinor) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_16, basicOperatorCompareEqualityMinor) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_16, basicOperatorCompareMajor) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_16, basicOperatorCompareEqualityMajor) {
audio::int8_16_t typeBase1(-12, 5);
audio::int8_16_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_16, basicOperatorLiteralPlus) {
audio::int8_16_t out;
out = audio::int8_16_t(-13, 5) + audio::int8_16_t(12, 5);
EXPECT_EQ(out.get(), audio::int8_16_t(-1,5).get());
}
TEST(TestInt8_16, basicOperatorLiteralMinus) {
audio::int8_16_t out;
out = audio::int8_16_t(-13, 5) - audio::int8_16_t(12, 5);
EXPECT_EQ(out.get(), audio::int8_16_t(-25,5).get());
}
TEST(TestInt8_16, basicOperatorLiteralMultiplication) {
audio::int8_16_t out;
out = audio::int8_16_t(-5, 3) * audio::int8_16_t(3, 3);
EXPECT_EQ(out.get(), audio::int8_16_t(-15,6).get());
}
TEST(TestInt8_16, basicOperatorDividing) {
audio::int8_16_t out(-15, 2);
out /= audio::int8_16_t(3, 2);
EXPECT_EQ(out.get(), audio::int8_16_t(-5,0).get());
}
TEST(TestInt8_16, basicOperatorLiteralDividing) {
audio::int8_16_t out;
out = audio::int8_16_t(-15, 2) / audio::int8_16_t(3, 2);
EXPECT_EQ(out.get(), audio::int8_16_t(-5,0).get());
}
TEST(TestInt8_16, basicOperatorIncrementPost) {
audio::int8_16_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int8_16_t(11, 0).get());
}
TEST(TestInt8_16, basicOperatorIncrementPre) {
audio::int8_16_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int8_16_t(11, 0).get());
}
TEST(TestInt8_16, basicOperatorDecrementPost) {
audio::int8_16_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int8_16_t(9, 0).get());
}
TEST(TestInt8_16, basicOperatorDecrementPre) {
audio::int8_16_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int8_16_t(9, 0).get());
}
#define RESULT_VALUE (80)
TEST(TestInt8_16, basicConstructorInt8_8) {
audio::int8_16_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt8_16) {
audio::int8_16_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt16_16) {
audio::int8_16_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt24_24) {
audio::int8_16_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt24_32) {
audio::int8_16_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt16_32) {
audio::int8_16_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt32_32) {
audio::int8_16_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt32_64) {
audio::int8_16_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorInt64_64) {
audio::int8_16_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorFloat) {
audio::int8_16_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_16, basicConstructorDouble) {
audio::int8_16_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}

View File

@ -9,30 +9,227 @@
#include <audio/types.h>
TEST(TestInt8_8, basicOperator) {
TEST(TestInt8_8, basicConstructorBase) {
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());
EXPECT_EQ(typeBase.get(), 16);
}
TEST(TestInt8_8, basicConstructorSetOne) {
audio::int8_8_t typeBase(1, 0);
EXPECT_EQ(typeBase.get(), ((1LL<<7)-1));
}
TEST(TestInt8_8, basicConstructorSetLessOne) {
audio::int8_8_t typeBase(-1, 0);
EXPECT_EQ(typeBase.get(), (-(1LL<<7)));
}
TEST(TestInt8_8, basicOperatorEqual) {
audio::int8_8_t typeBase;
typeBase = 35;
EXPECT_EQ(typeBase.get(), 35);
}
TEST(TestInt8_8, basicOperatorPlus) {
audio::int8_8_t typeBase(35);
typeBase += 35;
EXPECT_EQ(typeBase.get(), 70);
}
TEST(TestInt8_8, basicOperatorMinus) {
audio::int8_8_t typeBase(55);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), 20);
typeBase -= 35;
EXPECT_EQ(typeBase.get(), -15);
}
TEST(TestInt8_8, basicOperatorMultiplication) {
audio::int8_8_t typeBase(-1, 0);
typeBase *= 35;
EXPECT_EQ(typeBase.get(), -35);
typeBase = audio::int8_8_t(5, 3);
typeBase *= audio::int8_8_t(3, 3);
EXPECT_EQ(typeBase.get(), audio::int8_8_t(15, 6).get());
}
TEST(TestInt8_8, basicOperatorCompareEquality) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 == typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 == typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_8, basicOperatorCompareInEquality) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 != typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 != typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_8, basicOperatorCompareMinor) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 < typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_8, basicOperatorCompareEqualityMinor) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(12, 5);
result = typeBase1 <= typeBase2;
EXPECT_EQ(result, true);
}
TEST(TestInt8_8, basicOperatorCompareMajor) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
typeBase2.set(-15, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 > typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_8, basicOperatorCompareEqualityMajor) {
audio::int8_8_t typeBase1(-12, 5);
audio::int8_8_t typeBase2(-12, 5);
bool result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(-15, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, true);
typeBase2.set(12, 5);
result = typeBase1 >= typeBase2;
EXPECT_EQ(result, false);
}
TEST(TestInt8_8, basicOperatorLiteralPlus) {
audio::int8_8_t out;
out = audio::int8_8_t(-13, 5) + audio::int8_8_t(12, 5);
EXPECT_EQ(out.get(), audio::int8_8_t(-1,5).get());
}
TEST(TestInt8_8, basicOperatorLiteralMinus) {
audio::int8_8_t out;
out = audio::int8_8_t(-13, 5) - audio::int8_8_t(12, 5);
EXPECT_EQ(out.get(), audio::int8_8_t(-25,5).get());
}
TEST(TestInt8_8, basicOperatorLiteralMultiplication) {
audio::int8_8_t out;
out = audio::int8_8_t(-5, 3) * audio::int8_8_t(3, 3);
EXPECT_EQ(out.get(), audio::int8_8_t(-15,6).get());
}
TEST(TestInt8_8, basicOperatorDividing) {
audio::int8_8_t out(-15, 5);
out /= audio::int8_8_t(3, 2);
EXPECT_EQ(out.get(), audio::int8_8_t(-5,3).get());
}
TEST(TestInt8_8, basicOperatorLiteralDividing) {
audio::int8_8_t out;
out = audio::int8_8_t(-15, 5) / audio::int8_8_t(3, 2);
EXPECT_EQ(out.get(), audio::int8_8_t(-5,3).get());
}
/*
TEST(TestInt8_8, basicOperatorIncrementPost) {
audio::int8_8_t out(10, 0);
out++;
EXPECT_EQ(out.get(), audio::int8_8_t(11, 0).get());
}
TEST(TestInt8_8, basicOperatorIncrementPre) {
audio::int8_8_t out(10, 0);
++out;
EXPECT_EQ(out.get(), audio::int8_8_t(11, 0).get());
}
TEST(TestInt8_8, basicOperatorDecrementPost) {
audio::int8_8_t out(10, 0);
out--;
EXPECT_EQ(out.get(), audio::int8_8_t(9, 0).get());
}
TEST(TestInt8_8, basicOperatorDecrementPre) {
audio::int8_8_t out(10, 0);
--out;
EXPECT_EQ(out.get(), audio::int8_8_t(9, 0).get());
}
*/
#define RESULT_VALUE (40)
TEST(TestInt8_8, basicConstructorInt8_8) {
audio::int8_8_t out(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt8_16) {
audio::int8_8_t out(audio::int8_16_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt16_16) {
audio::int8_8_t out(audio::int16_16_t(5,4));
APPL_INFO(audio::int8_8_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt24_24) {
audio::int8_8_t out(audio::int24_24_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt24_32) {
audio::int8_8_t out(audio::int24_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt16_32) {
audio::int8_8_t out(audio::int16_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt32_32) {
audio::int8_8_t out(audio::int32_32_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt32_64) {
audio::int8_8_t out(audio::int32_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorInt64_64) {
audio::int8_8_t out(audio::int64_64_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorFloat) {
audio::int8_8_t out(audio::float_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}
TEST(TestInt8_8, basicConstructorDouble) {
audio::int8_8_t out(audio::double_t(5,4));
EXPECT_EQ(RESULT_VALUE, out.get());
}