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

View File

@ -236,7 +236,7 @@ namespace cw
void report( handle_t h );
// 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;
const object_t* cfg = args.test_args;
d_t* mtx0 = nullptr;
d_t* mtx1 = nullptr;
@ -135,7 +136,7 @@ cw::rc_t cw::mtx::test( const object_t* cfg )
mtx_y1 = allocCfg<double>(y1);
unsigned n = offset(*mtx1,1,1);
printf("offset: %i\n",n);
cwLogPrint("offset: %i\n",n);
report(*mtx0,"m0");

18
cwMtx.h
View File

@ -732,7 +732,7 @@ namespace cw
double v = ele( m, idxV );
// print the value
printf("%*.*f ",colWidth,decPl,v);
cwLogPrint("%*.*f ",colWidth,decPl,v);
}
else
{
@ -742,11 +742,11 @@ namespace cw
{
// print the dimension index for matrices with 3+ dim's
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
if( m.dimN>1 )
printf("%i | ",j);
cwLogPrint("%i | ",j);
}
idxV[i] = j;
@ -755,7 +755,7 @@ namespace cw
// prevent multiple newlines on last printed line
if( m.dimN==1 || (m.dimN>=2 && i > m.dimN-2) )
printf("\n");
cwLogPrint("\n");
}
}
@ -774,10 +774,10 @@ namespace cw
template< typename T >
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)
printf("%i ", m.dimV[i] );
printf("\n");
cwLogPrint("%i ", m.dimV[i] );
cwLogPrint("\n");
print(m,decPl,colWidth);
}
@ -896,7 +896,7 @@ namespace cw
if( mcn != xrn )
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 );
@ -936,7 +936,7 @@ namespace cw
typedef struct mtx_str<float> f_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 "cwFileSys.h"
#include "cwVectOps.h"
#include "cwTextBuf.h"
#include "cwAudioDevice.h"
#include "cwAudioBufDecls.h"
#include "cwAudioBuf.h"
#include "cwMtx.h"
#include "cwFlowTest.h"
@ -32,6 +39,9 @@ namespace cw
{ "/vop", vop::test },
{ "/time", time::test },
{ "/flow", flow::test },
{ "/textBuf", textBuf::test },
{ "/audioBuf",audio::buf::test },
{ "/mtx", mtx::test },
{ nullptr, nullptr },
};
@ -426,9 +436,22 @@ namespace cw
rc_t rc = kOkRC;
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() )
{
case kStringTId:
case kStringTId: // an external module file was given
{
const char* s = nullptr;
if((rc = module_cfg->value(s)) != kOkRC )
@ -441,7 +464,7 @@ namespace cw
}
break;
case kDictTId:
case kDictTId: // a nested module dict or case dict was given
rc = _proc_test_cfg(test, new_module_label, module_cfg );
break;
@ -450,6 +473,7 @@ namespace cw
}
errLabel:
mem::release(out_dir);
mem::release(new_module_label);
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 )
{
cases_cfg = test_cfg;

View File

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

View File

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