Merge branch 'poly' of gitea.larke.org:kevin/libcw into poly

This commit is contained in:
kevin 2024-06-01 08:03:00 -04:00
commit 6b7445c3d5
7 changed files with 47 additions and 21 deletions

View File

@ -992,7 +992,7 @@ void cw::audio::buf::report(handle_t h)
/// [cwAudioBufExample] /// [cwAudioBufExample]
cw::rc_t cw::audio::buf::test() cw::rc_t cw::audio::buf::test(const test::test_args_t& args)
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
unsigned devIdx = 0; unsigned devIdx = 0;
@ -1087,8 +1087,8 @@ cw::rc_t cw::audio::buf::test()
} }
for(i=0; i<sigN; ++i) for(i=0; i<sigN; ++i)
cwLogInfo("%f ",oSig[i]); cwLogPrint("%f ",oSig[i]);
cwLogInfo("\n"); cwLogPrint("\n");
destroy(h); destroy(h);

View File

@ -236,7 +236,7 @@ namespace cw
void report( handle_t h ); void report( handle_t h );
// Run a buffer usage simulation to test the class. cmAudioPortTest.c calls this function. // Run a buffer usage simulation to test the class. cmAudioPortTest.c calls this function.
rc_t test(); rc_t test(const test::test_args_t& args);
//) //)

View File

@ -89,9 +89,10 @@ namespace cw
cw::rc_t cw::mtx::test( const object_t* cfg ) cw::rc_t cw::mtx::test( const test::test_args_t& args )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
const object_t* cfg = args.test_args;
d_t* mtx0 = nullptr; d_t* mtx0 = nullptr;
d_t* mtx1 = nullptr; d_t* mtx1 = nullptr;
@ -135,7 +136,7 @@ cw::rc_t cw::mtx::test( const object_t* cfg )
mtx_y1 = allocCfg<double>(y1); mtx_y1 = allocCfg<double>(y1);
unsigned n = offset(*mtx1,1,1); unsigned n = offset(*mtx1,1,1);
printf("offset: %i\n",n); cwLogPrint("offset: %i\n",n);
report(*mtx0,"m0"); report(*mtx0,"m0");

18
cwMtx.h
View File

@ -732,7 +732,7 @@ namespace cw
double v = ele( m, idxV ); double v = ele( m, idxV );
// print the value // print the value
printf("%*.*f ",colWidth,decPl,v); cwLogPrint("%*.*f ",colWidth,decPl,v);
} }
else else
{ {
@ -742,11 +742,11 @@ namespace cw
{ {
// print the dimension index for matrices with 3+ dim's // print the dimension index for matrices with 3+ dim's
if( i > 0 && j == 0 ) if( i > 0 && j == 0 )
printf("%i\n",idxV[i-1]); cwLogPrint("%i\n",idxV[i-1]);
// print the row index for matrices with 2+ dim's // print the row index for matrices with 2+ dim's
if( m.dimN>1 ) if( m.dimN>1 )
printf("%i | ",j); cwLogPrint("%i | ",j);
} }
idxV[i] = j; idxV[i] = j;
@ -755,7 +755,7 @@ namespace cw
// prevent multiple newlines on last printed line // prevent multiple newlines on last printed line
if( m.dimN==1 || (m.dimN>=2 && i > m.dimN-2) ) if( m.dimN==1 || (m.dimN>=2 && i > m.dimN-2) )
printf("\n"); cwLogPrint("\n");
} }
} }
@ -774,10 +774,10 @@ namespace cw
template< typename T > template< typename T >
void report( const struct mtx_str<T>& m, const char* label, unsigned decPl=3, unsigned colWidth=10 ) void report( const struct mtx_str<T>& m, const char* label, unsigned decPl=3, unsigned colWidth=10 )
{ {
printf("%s :",label); cwLogPrint("%s :",label);
for(unsigned i=0; i<m.dimN; ++i) for(unsigned i=0; i<m.dimN; ++i)
printf("%i ", m.dimV[i] ); cwLogPrint("%i ", m.dimV[i] );
printf("\n"); cwLogPrint("\n");
print(m,decPl,colWidth); print(m,decPl,colWidth);
} }
@ -896,7 +896,7 @@ namespace cw
if( mcn != xrn ) if( mcn != xrn )
return cwLogError(kInvalidArgRC, "Mtx mult. failed. Size mismatch: m[%i,%i] x[%i,%i].",mrn,mcn,xrn,xcn); return cwLogError(kInvalidArgRC, "Mtx mult. failed. Size mismatch: m[%i,%i] x[%i,%i].",mrn,mcn,xrn,xcn);
//printf("%i %i : %i %i\n",mrn,mcn,xrn,xcn); //cwLogPrint("%i %i : %i %i\n",mrn,mcn,xrn,xcn);
resize(&y,yDimV, 2 ); resize(&y,yDimV, 2 );
@ -936,7 +936,7 @@ namespace cw
typedef struct mtx_str<float> f_t; typedef struct mtx_str<float> f_t;
typedef struct mtx_str<double> d_t; typedef struct mtx_str<double> d_t;
rc_t test( const struct object_str* cfg ); rc_t test( const test::test_args_t& args );
} }

View File

@ -12,6 +12,13 @@
#include "cwFile.h" #include "cwFile.h"
#include "cwFileSys.h" #include "cwFileSys.h"
#include "cwVectOps.h" #include "cwVectOps.h"
#include "cwTextBuf.h"
#include "cwAudioDevice.h"
#include "cwAudioBufDecls.h"
#include "cwAudioBuf.h"
#include "cwMtx.h"
#include "cwFlowTest.h" #include "cwFlowTest.h"
@ -32,6 +39,9 @@ namespace cw
{ "/vop", vop::test }, { "/vop", vop::test },
{ "/time", time::test }, { "/time", time::test },
{ "/flow", flow::test }, { "/flow", flow::test },
{ "/textBuf", textBuf::test },
{ "/audioBuf",audio::buf::test },
{ "/mtx", mtx::test },
{ nullptr, nullptr }, { nullptr, nullptr },
}; };
@ -426,9 +436,22 @@ namespace cw
rc_t rc = kOkRC; rc_t rc = kOkRC;
char* new_module_label = filesys::makeFn(base_module_label,nullptr,nullptr,module_label,nullptr ); char* new_module_label = filesys::makeFn(base_module_label,nullptr,nullptr,module_label,nullptr );
// form the module output directory
char* out_dir = filesys::makeFn(test.base_dir,nullptr,nullptr,test.out_folder,new_module_label,nullptr);
// verify that the the module output directory exists
if( !filesys::isDir(out_dir) )
{
if((rc = filesys::makeDir(out_dir)) != kOkRC )
{
rc = cwLogError(rc,"The module output directory '%s' create failed.",cwStringNullGuard(out_dir));
goto errLabel;
}
}
switch( module_cfg->type_id() ) switch( module_cfg->type_id() )
{ {
case kStringTId: case kStringTId: // an external module file was given
{ {
const char* s = nullptr; const char* s = nullptr;
if((rc = module_cfg->value(s)) != kOkRC ) if((rc = module_cfg->value(s)) != kOkRC )
@ -441,7 +464,7 @@ namespace cw
} }
break; break;
case kDictTId: case kDictTId: // a nested module dict or case dict was given
rc = _proc_test_cfg(test, new_module_label, module_cfg ); rc = _proc_test_cfg(test, new_module_label, module_cfg );
break; break;
@ -450,6 +473,7 @@ namespace cw
} }
errLabel: errLabel:
mem::release(out_dir);
mem::release(new_module_label); mem::release(new_module_label);
return rc; return rc;
} }
@ -485,7 +509,7 @@ namespace cw
} }
} }
// if // if no keywords were found then the dictionary must be a list of cases
if(module_args==nullptr && modules_cfg==nullptr && cases_cfg==nullptr ) if(module_args==nullptr && modules_cfg==nullptr && cases_cfg==nullptr )
{ {
cases_cfg = test_cfg; cases_cfg = test_cfg;

View File

@ -1,6 +1,7 @@
#include "cwCommon.h" #include "cwCommon.h"
#include "cwLog.h" #include "cwLog.h"
#include "cwCommonImpl.h" #include "cwCommonImpl.h"
#include "cwTest.h"
#include "cwMem.h" #include "cwMem.h"
#include "cwTextBuf.h" #include "cwTextBuf.h"
@ -164,7 +165,7 @@ cw::rc_t cw::textBuf::setFloatFormat( handle_t h, unsigned width, unsigned decPl
return kOkRC; return kOkRC;
} }
cw::rc_t cw::textBuf::test() cw::rc_t cw::textBuf::test( const test::test_args_t& args )
{ {
handle_t h; handle_t h;
rc_t rc; rc_t rc;
@ -175,7 +176,7 @@ cw::rc_t cw::textBuf::test()
print(h,"Hello\n"); print(h,"Hello\n");
print(h,"foo\n"); print(h,"foo\n");
printf("%s", text(h) ); cwLogPrint("%s", text(h) );
return destroy(h); return destroy(h);
} }

View File

@ -28,7 +28,7 @@ namespace cw
rc_t setIntFormat( handle_t h, unsigned width, unsigned flags ); rc_t setIntFormat( handle_t h, unsigned width, unsigned flags );
rc_t setFloatFormat( handle_t h, unsigned width, unsigned decPlN ); rc_t setFloatFormat( handle_t h, unsigned width, unsigned decPlN );
rc_t test(); rc_t test( const test::test_args_t& args);
} }
} }