Re: Fake getopt cli options from in script.
- Date: Wed, 10 Apr 2019 06:50:33 +0000
- From: Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: Fake getopt cli options from in script.
On April 4, 2019 5:49:48 AM UTC, Ronald Fenner <rfenner@xxxxxxxxxxxxxx> wrote:
>I'm trying to fake passing some CLI option that getup wold read to unit
>test a function.
>A stack overflow post from 7 years ago suggested setting the argc and
>I've tried that but getup doesn't seem to see them. The
>register_argc_argv setting is off.
>Is the 7yr old method still valid or is there another way to do it.
>Game Circus LLC.
If the code you're testing is namespaced, you can redefine getopt within that namespace. The unit tests will look against the local namespace first, before looking for the global level function.