Re: Unit testing a function returning void

2022-11-03 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 3 November 2022 at 10:26:04 UTC, Imperatorn wrote: On Thursday, 3 November 2022 at 10:00:27 UTC, Bruno Pagis wrote: Good morning, I have the following class: ``` class A { int[] array; ... void print() { writeln("array = ", this.array); } } ``` I would like to unit t

Re: Unit testing a function returning void

2022-11-03 Thread Sergey via Digitalmars-d-learn
On Thursday, 3 November 2022 at 10:00:27 UTC, Bruno Pagis wrote: Good morning, I would like to unit test the print function (yes, I know, not very useful on the above example since print is merely a duplicate of writeln...). Is there a way to use assert to test the output of the print functio

Re: Unit testing a function returning void

2022-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 03, 2022 at 08:51:52AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 11/3/22 03:00, Bruno Pagis wrote: > > >void print() { > > writeln("array = ", this.array); > >} > > Similar to Paul Backus's program but I would try to avoid the file system > for unit tests wh

Re: Unit testing a function returning void

2022-11-03 Thread Ali Çehreli via Digitalmars-d-learn
On 11/3/22 03:00, Bruno Pagis wrote: >void print() { > writeln("array = ", this.array); >} Similar to Paul Backus's program but I would try to avoid the file system for unit tests when possible. In this case, you can print into a sink, which can be useful in other ways as well:

Re: Unit testing a function returning void

2022-11-03 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 3 November 2022 at 10:00:27 UTC, Bruno Pagis wrote: Good morning, I have the following class: ``` class A { int[] array; ... void print() { writeln("array = ", this.array); } } ``` I would like to unit test the print function (yes, I know, not very useful on the abov

Re: Unit testing a function returning void

2022-11-03 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 3 November 2022 at 10:00:27 UTC, Bruno Pagis wrote: Good morning, I have the following class: ``` class A { int[] array; ... void print() { writeln("array = ", this.array); } } ``` I would like to unit test the print function (yes, I know, not very useful on the abov

Re: Unit testing a function returning void

2022-11-03 Thread rikki cattermole via Digitalmars-d-learn
You could redirect stdout to a file of your choosing and test against that. Although ideally you would instead take as an argument to print some sort of output range or Appender. Then you could test against that instead.

Re: unit testing version statements

2014-08-22 Thread Dicebot via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote: On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option This is how version feature is intentionally designed to work

Re: unit testing version statements

2014-08-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote: On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option Well, that's normally how it would be done. But if you need to test them all with

Re: unit testing version statements

2014-08-22 Thread Robert burner Schadek via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option

Re: unit testing version statements

2014-08-22 Thread Kagamin via Digitalmars-d-learn
Compile and run the tests with different version options.

Re: Unit testing D module

2013-12-26 Thread John Colvin
On Thursday, 26 December 2013 at 09:25:14 UTC, Dfr wrote: If i do not want to unit test whole codebase, because it big enough and all tests take noticeable time to run. So i trying this: dmd -unittest mymodule.d And getting error: "undefined reference to `main'" But i don't want to run 'main'

Re: Unit testing D module

2013-12-26 Thread Chris Cain
On Thursday, 26 December 2013 at 09:25:14 UTC, Dfr wrote: If i do not want to unit test whole codebase, because it big enough and all tests take noticeable time to run. So i trying this: dmd -unittest mymodule.d And getting error: "undefined reference to `main'" But i don't want to run 'main'

Re: unit testing

2011-03-28 Thread Ishan Thilina
- Jonathan M Davis wrote: >LOL. Goodness no. They're done by hand. I'm currently reworking std.datetime's >unit tests, and it's very time consuming (since it's a large module with lots >of tests). I don't know how you'd get a framework to generate what I want >anyway. The fact that D has unit test

Re: unit testing

2011-03-28 Thread Jonathan M Davis
On 2011-03-28 11:29, Ishan Thilina wrote: > @David: > > No, my question was not about running them,but on how that code was > generated. I thought they were auto generated using a unitest framework > :). Your answer clarifies everything. Thank you..! :-) LOL. Goodness no. They're done by hand. I'

Re: unit testing

2011-03-28 Thread Ishan Thilina
@David: No, my question was not about running them,but on how that code was generated. I thought they were auto generated using a unitest framework :). Your answer clarifies everything. Thank you..! :-)

Re: unit testing

2011-03-28 Thread David Nadlinger
On 3/28/11 5:55 PM, Caligo wrote: and how does one do unit testing with GDC? It works fine with DMD, but GDC doesn't do unit testing when -unittest is supplied. -funittest, IIRC. David

Re: unit testing

2011-03-28 Thread Caligo
On Mon, Mar 28, 2011 at 9:34 AM, David Nadlinger wrote: > On 3/28/11 4:23 PM, Ishan Thilina wrote: >> >> I see that almost all of the phobos library files have "unittests". Were >> these >> unit tests were created using some framework? If so, then what is it? >> >> Thank you...! > > No, these unit

Re: unit testing

2011-03-28 Thread David Nadlinger
On 3/28/11 4:23 PM, Ishan Thilina wrote: I see that almost all of the phobos library files have "unittests". Were these unit tests were created using some framework? If so, then what is it? Thank you...! No, these unit test were just written by hand while writing the corresponding pieces of c