From 6f2d6ee4554af4e60e40cfbc585ef1a37abb6bea Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 30 May 2024 09:20:41 -0400 Subject: [PATCH] cwAudioBuf,cwMtx,cwTextBuf,cwTest : Moved audioBuf,mtx,a nd textBuf tests to cwTest. --- cwAudioBuf.cpp | 6 +++--- cwAudioBuf.h | 2 +- cwMtx.cpp | 5 +++-- cwMtx.h | 18 +++++++++--------- cwTest.cpp | 30 +++++++++++++++++++++++++++--- cwTextBuf.cpp | 5 +++-- cwTextBuf.h | 2 +- 7 files changed, 47 insertions(+), 21 deletions(-) diff --git a/cwAudioBuf.cpp b/cwAudioBuf.cpp index 905925f..aef77db 100644 --- a/cwAudioBuf.cpp +++ b/cwAudioBuf.cpp @@ -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(y1); unsigned n = offset(*mtx1,1,1); - printf("offset: %i\n",n); + cwLogPrint("offset: %i\n",n); report(*mtx0,"m0"); diff --git a/cwMtx.h b/cwMtx.h index 4121e13..d364b5e 100644 --- a/cwMtx.h +++ b/cwMtx.h @@ -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& m, const char* label, unsigned decPl=3, unsigned colWidth=10 ) { - printf("%s :",label); + cwLogPrint("%s :",label); for(unsigned i=0; i f_t; typedef struct mtx_str d_t; - rc_t test( const struct object_str* cfg ); + rc_t test( const test::test_args_t& args ); } diff --git a/cwTest.cpp b/cwTest.cpp index b656db0..3bacda9 100644 --- a/cwTest.cpp +++ b/cwTest.cpp @@ -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 }, }; @@ -425,10 +435,23 @@ 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; diff --git a/cwTextBuf.cpp b/cwTextBuf.cpp index df1c60c..9a25c74 100644 --- a/cwTextBuf.cpp +++ b/cwTextBuf.cpp @@ -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); } diff --git a/cwTextBuf.h b/cwTextBuf.h index 936aaf4..9bf899e 100644 --- a/cwTextBuf.h +++ b/cwTextBuf.h @@ -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); } }