[Csnd-dev] Unit Testing

Steven Yi <[email protected]>
Newsgroups gmane.comp.audio.csound.devel
Message-ID <CANtcCs7avyhrQ1GvHPh_Cx1UMhkO5Ajb_WWzJLw=HwY1t3Azeg@mail.gmail.com>
Hi All,

While doing the pass-by-ref work, I experimented with writing some
assert UDOs. I found this worked out well, and suggest we spend a
little time to create a unit-testing .orc library to support our
unit-testing needs for orc code. Here are two example UDOs I put
together:

opcode assert(condition:b, message:S):void
    if(!condition) then
        prints(message)
        exitnow(-1)
    endif
endop

opcode assertEquals(ival, iexpected):void
    if(ival != iexpected) then
        prints("Error: ival was %g, expected %g\n", ival, iexpected)
        exitnow(-1)
    endif
endop

I suspect this would be good not-only as part of our tests but more
broadly for Csound users developing their own code. We could look at
having a separate repo for this and add it as a git submodule, or
perhaps some other approach. (Ideas welcome here.)

Cheers!
Steven
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.